Issues Report
myandroidutil - Oct 14, 2016 6:50:37 PM

New issues

5017

Resolved issues

0

1
New issues
Add a 'package-info.java' file to document the 'utilcode' package     NEW     squid:S1228
Packages should have a javadoc file 'package-info.java'
7
New issues
Add or update the header of this file.     NEW     squid:S1451
Copyright and license headers should be defined
Add a new line at the end of this file.     NEW     squid:S00113
Files should contain an empty new line at the end
1
package com.blankj.utilcode;
2

                  
7
 * <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
8
 */
9
public class ApplicationTest extends ApplicationTestCase<Application> {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
10
    public ApplicationTest() {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Make this line start at column 3.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Document this public constructor.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
11
        super(Application.class);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
12
    }
13
}
1
New issues
Add a 'package-info.java' file to document the 'utils' package     NEW     squid:S1228
Packages should have a javadoc file 'package-info.java'
12
New issues
Add or update the header of this file.     NEW     squid:S1451
Copyright and license headers should be defined
1
package com.blankj.utilcode.utils;
2

                  
13
 * </pre>
14
 */
15
public class ActivityUtils {
Make this class "final" or add a public constructor.     NEW     squid:S2974  
Classes without "public" constructors should be "final"
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
16

                  
17
    private ActivityUtils() {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Make this line start at column 3.     NEW     squid:IndentationCheck  
Source code should be indented consistently
18
        throw new UnsupportedOperationException("u can't instantiate me...");
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
19
    }
20

                  
27
     * @return {@code true}: 是<br>{@code false}: 否
28
     */
29
    public static boolean isExistActivity(Context context, String packageName, String className) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
30
        Intent intent = new Intent();
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
31
        intent.setClassName(packageName, className);
32
        return !(context.getPackageManager().resolveActivity(intent, 0) == null ||
42
     * @param className   全类名
43
     */
44
    public static void launchActivity(Context context, String packageName, String className) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
45
        launchActivity(context, packageName, className, null);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
46
    }
47

                  
54
     * @param bundle      bundle
55
     */
56
    public static void launchActivity(Context context, String packageName, String className, Bundle bundle) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
57
        context.startActivity(IntentUtils.getComponentIntent(packageName, className, bundle));
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
58
    }
59
}
250
New issues
Add or update the header of this file.     NEW     squid:S1451
Copyright and license headers should be defined
Replace all tab characters in this file by sequences of white-spaces.     NEW     squid:S00105
Tabulation characters should not be used
1
package com.blankj.utilcode.utils;
2

                  
12
import java.security.MessageDigest;
13
import java.security.NoSuchAlgorithmException;
14
import java.io.BufferedReader;
Remove this unused import 'java.io.BufferedReader'.     NEW     squid:UselessImportCheck  
Useless imports should be removed
15
import java.io.File;
16
import java.io.IOException;
Remove this unused import 'java.io.IOException'.     NEW     squid:UselessImportCheck  
Useless imports should be removed
17
import java.io.InputStreamReader;
Remove this unused import 'java.io.InputStreamReader'.     NEW     squid:UselessImportCheck  
Useless imports should be removed
18
import java.io.OutputStream;
Remove this unused import 'java.io.OutputStream'.     NEW     squid:UselessImportCheck  
Useless imports should be removed
19
import java.util.ArrayList;
20
import java.util.List;
28
 * </pre>
29
 */
30
public class AppUtils {
Make this class "final" or add a public constructor.     NEW     squid:S2974  
Classes without "public" constructors should be "final"
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
class "AppUtils" has 38 methods, which is greater than the 35 authorized. Split it into smaller classes.     NEW     squid:S1448  
Classes should not have too many methods
31

                  
32
    private AppUtils() {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Make this line start at column 3.     NEW     squid:IndentationCheck  
Source code should be indented consistently
33
        throw new UnsupportedOperationException("u can't instantiate me...");
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
34
    }
35
    
40
	 * @return 应用的 SHA1 字符串, 比如: 53:FD:54:DC:19:0F:11:AC:B5:22:9E:F1:1A:68:88:1B:8B:E8:54:42
41
     */
42
	public static String getSHA1(Context context) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
43
		try {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
44
			PackageInfo info = context.getPackageManager().getPackageInfo(
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
45
					context.getPackageName(), PackageManager.GET_SIGNATURES);
46
			byte[] cert = info.signatures[0].toByteArray();
47
			MessageDigest md = MessageDigest.getInstance("SHA1");
Use a stronger hashing algorithm than SHA-1.     NEW     squid:S2070  
SHA-1 and Message-Digest hash algorithms should not be used
48
			byte[] publicKey = md.digest(cert);
49
			StringBuilder hexString = new StringBuilder();
50
			for (byte aPublicKey : publicKey) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
51
				String appendString = Integer.toHexString(0xFF & aPublicKey).toUpperCase();
Define the locale to be used in this String operation.     NEW     squid:S1449  
Locale should be used in String operations
Make this line start at column 9.     NEW     squid:IndentationCheck  
Source code should be indented consistently
52
				if (appendString.length() == 1)
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
53
					hexString.append("0");
54
				hexString.append(appendString);
57
			String result = hexString.toString();
58
			return result.substring(0, result.length() - 1);
59
		} catch (PackageManager.NameNotFoundException | NoSuchAlgorithmException e) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "catch" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
Either log or rethrow this exception.     NEW     squid:S1166  
Exception handlers should preserve the original exceptions
60
			e.printStackTrace();
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
61
		}
62
		return "";
71
     * @return {@code true}: 已安装<br>{@code false}: 未安装
72
     */
73
    public static boolean isInstallApp(Context context, String packageName) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
74
        return !StringUtils.isSpace(packageName) && IntentUtils.getLaunchAppIntent(context, packageName) != null;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
75
    }
76

                  
81
     * @param filePath 文件路径
82
     */
83
    public static void installApp(Context context, String filePath) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
84
        installApp(context, FileUtils.getFileByPath(filePath));
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
85
    }
86

                  
91
     * @param file    文件
92
     */
93
    public static void installApp(Context context, File file) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
94
        if (!FileUtils.isFileExists(file)) return;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
95
        context.startActivity(IntentUtils.getInstallAppIntent(file));
96
    }
103
     * @param requestCode 请求值
104
     */
105
    public static void installApp(Activity activity, String filePath, int requestCode) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
106
        installApp(activity, FileUtils.getFileByPath(filePath), requestCode);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
107
    }
108

                  
114
     * @param requestCode 请求值
115
     */
116
    public static void installApp(Activity activity, File file, int requestCode) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
117
        if (!FileUtils.isFileExists(file)) return;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
118
        activity.startActivityForResult(IntentUtils.getInstallAppIntent(file), requestCode);
119
    }
127
     * @return {@code true}: 安装成功<br>{@code false}: 安装失败
128
     */
129
    public static boolean installAppSilent(Context context, String filePath) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
130
        File file = FileUtils.getFileByPath(filePath);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
131
        if (!FileUtils.isFileExists(file)) return false;
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
132
        String command = "LD_LIBRARY_PATH=/vendor/lib:/system/lib pm install " + filePath;
133
        ShellUtils.CommandResult commandResult = ShellUtils.execCmd(command, !isSystemApp(context), true);
141
     * @param packageName 包名
142
     */
143
    public static void uninstallApp(Context context, String packageName) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
144
        if (StringUtils.isSpace(packageName)) return;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
145
        context.startActivity(IntentUtils.getUninstallAppIntent(packageName));
146
    }
153
     * @param requestCode 请求值
154
     */
155
    public static void uninstallApp(Activity activity, String packageName, int requestCode) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
156
        if (StringUtils.isSpace(packageName)) return;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
157
        activity.startActivityForResult(IntentUtils.getUninstallAppIntent(packageName), requestCode);
158
    }
167
     * @return {@code true}: 卸载成功<br>{@code false}: 卸载成功
168
     */
169
    public static boolean uninstallAppSilent(Context context, String packageName, boolean isKeepData) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Provide multiple methods instead of using "isKeepData" to determine which action to take.     NEW     squid:S2301  
Public methods should not contain selector arguments
170
        if (StringUtils.isSpace(packageName)) return false;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
171
        String command = "LD_LIBRARY_PATH=/vendor/lib:/system/lib pm uninstall " + (isKeepData ? "-k " : "") + packageName;
Convert this usage of the ternary operator to an "if"/"else" structure.     NEW     squid:S1774  
The ternary operator should not be used
Split this 123 characters long line (which is greater than 120 authorized).     NEW     squid:S00103  
Lines should not be too long
172
        ShellUtils.CommandResult commandResult = ShellUtils.execCmd(command, !isSystemApp(context), true);
173
        return commandResult.successMsg != null && commandResult.successMsg.toLowerCase().contains("success");
180
     * @param packageName 包名
181
     */
182
    public static void launchApp(Context context, String packageName) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
183
        if (StringUtils.isSpace(packageName)) return;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
184
        context.startActivity(IntentUtils.getLaunchAppIntent(context, packageName));
185
    }
192
     * @param requestCode 请求值
193
     */
194
    public static void launchApp(Activity activity, String packageName, int requestCode) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
195
        if (StringUtils.isSpace(packageName)) return;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
196
        activity.startActivityForResult(IntentUtils.getLaunchAppIntent(activity, packageName), requestCode);
197
    }
203
     * @return App包名
204
     */
205
    public static String getAppPackageName(Context context) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
206
        return context.getPackageName();
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
207
    }
208

                  
212
     * @param context 上下文
213
     */
214
    public static void getAppDetailsSettings(Context context) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
215
        getAppDetailsSettings(context, context.getPackageName());
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
216
    }
217

                  
222
     * @param packageName 包名
223
     */
224
    public static void getAppDetailsSettings(Context context, String packageName) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
225
        if (StringUtils.isSpace(packageName)) return;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
226
        context.startActivity(IntentUtils.getAppDetailsSettingsIntent(packageName));
227
    }
233
     * @return App名称
234
     */
235
    public static String getAppName(Context context) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
236
        return getAppName(context, context.getPackageName());
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
237
    }
238

                  
244
     * @return App名称
245
     */
246
    public static String getAppName(Context context, String packageName) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
247
        if (StringUtils.isSpace(packageName)) return null;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
248
        try {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
249
            PackageManager pm = context.getPackageManager();
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
250
            PackageInfo pi = pm.getPackageInfo(packageName, 0);
251
            return pi == null ? null : pi.applicationInfo.loadLabel(pm).toString();
Convert this usage of the ternary operator to an "if"/"else" structure.     NEW     squid:S1774  
The ternary operator should not be used
252
        } catch (PackageManager.NameNotFoundException e) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "catch" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
Either log or rethrow this exception.     NEW     squid:S1166  
Exception handlers should preserve the original exceptions
253
            e.printStackTrace();
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
254
            return null;
255
        }
262
     * @return App图标
263
     */
264
    public static Drawable getAppIcon(Context context) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
265
        return getAppIcon(context, context.getPackageName());
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
266
    }
267

                  
273
     * @return App图标
274
     */
275
    public static Drawable getAppIcon(Context context, String packageName) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
276
        if (StringUtils.isSpace(packageName)) return null;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
277
        try {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
278
            PackageManager pm = context.getPackageManager();
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
279
            PackageInfo pi = pm.getPackageInfo(packageName, 0);
280
            return pi == null ? null : pi.applicationInfo.loadIcon(pm);
Convert this usage of the ternary operator to an "if"/"else" structure.     NEW     squid:S1774  
The ternary operator should not be used
281
        } catch (PackageManager.NameNotFoundException e) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "catch" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
Either log or rethrow this exception.     NEW     squid:S1166  
Exception handlers should preserve the original exceptions
282
            e.printStackTrace();
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
283
            return null;
284
        }
291
     * @return App路径
292
     */
293
    public static String getAppPath(Context context) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
294
        return getAppPath(context, context.getPackageName());
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
295
    }
296

                  
302
     * @return App路径
303
     */
304
    public static String getAppPath(Context context, String packageName) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
305
        if (StringUtils.isSpace(packageName)) return null;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
306
        try {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
307
            PackageManager pm = context.getPackageManager();
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
308
            PackageInfo pi = pm.getPackageInfo(packageName, 0);
309
            return pi == null ? null : pi.applicationInfo.sourceDir;
Convert this usage of the ternary operator to an "if"/"else" structure.     NEW     squid:S1774  
The ternary operator should not be used
310
        } catch (PackageManager.NameNotFoundException e) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "catch" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
Either log or rethrow this exception.     NEW     squid:S1166  
Exception handlers should preserve the original exceptions
311
            e.printStackTrace();
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
312
            return null;
313
        }
320
     * @return App版本号
321
     */
322
    public static String getAppVersionName(Context context) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
323
        return getAppVersionName(context, context.getPackageName());
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
324
    }
325

                  
331
     * @return App版本号
332
     */
333
    public static String getAppVersionName(Context context, String packageName) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
334
        if (StringUtils.isSpace(packageName)) return null;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
335
        try {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
336
            PackageManager pm = context.getPackageManager();
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
337
            PackageInfo pi = pm.getPackageInfo(packageName, 0);
338
            return pi == null ? null : pi.versionName;
Convert this usage of the ternary operator to an "if"/"else" structure.     NEW     squid:S1774  
The ternary operator should not be used
339
        } catch (PackageManager.NameNotFoundException e) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "catch" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
Either log or rethrow this exception.     NEW     squid:S1166  
Exception handlers should preserve the original exceptions
340
            e.printStackTrace();
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
341
            return null;
342
        }
349
     * @return App版本码
350
     */
351
    public static int getAppVersionCode(Context context) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
352
        return getAppVersionCode(context, context.getPackageName());
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
353
    }
354

                  
360
     * @return App版本码
361
     */
362
    public static int getAppVersionCode(Context context, String packageName) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
363
        if (StringUtils.isSpace(packageName)) return -1;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
364
        try {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
365
            PackageManager pm = context.getPackageManager();
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
366
            PackageInfo pi = pm.getPackageInfo(packageName, 0);
367
            return pi == null ? -1 : pi.versionCode;
Convert this usage of the ternary operator to an "if"/"else" structure.     NEW     squid:S1774  
The ternary operator should not be used
368
        } catch (PackageManager.NameNotFoundException e) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "catch" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
Either log or rethrow this exception.     NEW     squid:S1166  
Exception handlers should preserve the original exceptions
369
            e.printStackTrace();
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
370
            return -1;
371
        }
378
     * @return App签名
379
     */
380
    public static Signature[] getAppSignature(Context context) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
381
        return getAppSignature(context, context.getPackageName());
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
382
    }
383

                  
389
     * @return App签名
390
     */
391
    public static Signature[] getAppSignature(Context context, String packageName) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
392
        if (StringUtils.isSpace(packageName)) return null;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Return an empty array instead of null.     NEW     squid:S1168  
Empty arrays and collections should be returned instead of null
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
393
        try {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
394
            PackageManager pm = context.getPackageManager();
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
395
            PackageInfo pi = pm.getPackageInfo(packageName, 0);
396
            return pi == null ? null : pi.signatures;
Convert this usage of the ternary operator to an "if"/"else" structure.     NEW     squid:S1774  
The ternary operator should not be used
397
        } catch (PackageManager.NameNotFoundException e) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "catch" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
Either log or rethrow this exception.     NEW     squid:S1166  
Exception handlers should preserve the original exceptions
398
            e.printStackTrace();
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
399
            return null;
Return an empty array instead of null.     NEW     squid:S1168  
Empty arrays and collections should be returned instead of null
400
        }
401
    }
407
     * @return {@code true}: 是<br>{@code false}: 否
408
     */
409
    public static boolean isSystemApp(Context context) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
410
        return isSystemApp(context, context.getPackageName());
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
411
    }
412

                  
418
     * @return {@code true}: 是<br>{@code false}: 否
419
     */
420
    public static boolean isSystemApp(Context context, String packageName) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
421
        if (StringUtils.isSpace(packageName)) return false;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
422
        try {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
423
            PackageManager pm = context.getPackageManager();
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
424
            ApplicationInfo ai = pm.getApplicationInfo(packageName, 0);
425
            return ai != null && (ai.flags & ApplicationInfo.FLAG_SYSTEM) != 0;
426
        } catch (PackageManager.NameNotFoundException e) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "catch" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
Either log or rethrow this exception.     NEW     squid:S1166  
Exception handlers should preserve the original exceptions
427
            e.printStackTrace();
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
428
        }
429
        return false;
438
     * @return {@code true}: 是<br>{@code false}: 否
439
     */
440
    public static boolean isAppForeground(Context context) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
441
        return isAppForeground(context, context.getPackageName());
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
442
    }
443

                  
450
     * @return {@code true}: 是<br>{@code false}: 否
451
     */
452
    public static boolean isAppForeground(Context context, String packageName) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document the parameter(s): packageName     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
453
        ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
454
        @SuppressWarnings("deprecation")
Suppressing warnings is not allowed     NEW     squid:S1309  
The @SuppressWarnings annotation should not be used
455
        List<ActivityManager.RunningTaskInfo> tasks = am.getRunningTasks(1);
456
        return tasks != null && !tasks.isEmpty()
461
     * 封装App信息的Bean类
462
     */
463
    public static class AppInfo {
Reduce this class from 97 to the maximum allowed 25 or externalize it in a public class.     NEW     squid:S2972  
Inner classes should not have too many lines
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Make this line start at column 3.     NEW     squid:IndentationCheck  
Source code should be indented consistently
464

                  
465
        private String name;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
466
        private Drawable icon;
467
        private String packageName;
471
        private boolean isSystem;
472

                  
473
        public Drawable getIcon() {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
474
            return icon;
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
475
        }
476

                  
477
        public void setIcon(Drawable icon) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
478
            this.icon = icon;
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
479
        }
480

                  
481
        public boolean isSystem() {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
482
            return isSystem;
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
483
        }
484

                  
485
        public void setSystem(boolean isSystem) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
486
            this.isSystem = isSystem;
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
487
        }
488

                  
489
        public String getName() {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
490
            return name;
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
491
        }
492

                  
493
        public void setName(String name) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
494
            this.name = name;
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
495
        }
496

                  
497
        public String getPackageName() {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
498
            return packageName;
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
499
        }
500

                  
501
        public void setPackageName(String packagName) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
502
            this.packageName = packagName;
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
503
        }
504

                  
505
        public String getPackagePath() {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
506
            return packagePath;
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
507
        }
508

                  
509
        public void setPackagePath(String packagePath) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
510
            this.packagePath = packagePath;
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
511
        }
512

                  
513
        public int getVersionCode() {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
514
            return versionCode;
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
515
        }
516

                  
517
        public void setVersionCode(int versionCode) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
518
            this.versionCode = versionCode;
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
519
        }
520

                  
521
        public String getVersionName() {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
522
            return versionName;
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
523
        }
524

                  
525
        public void setVersionName(String versionName) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
526
            this.versionName = versionName;
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
527
        }
528

                  
536
         * @param isSystem    是否系统应用
537
         */
538
        public AppInfo(String name, Drawable icon, String packageName, String packagePath,
Move this constructor to comply with Java Code Conventions.     NEW     squid:S1213  
The members of an interface declaration or class should appear in a pre-defined order
539
                       String versionName, int versionCode, boolean isSystem) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
540
            this.setName(name);
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Remove this call from a constructor to the overridable "setName" method.     NEW     squid:S1699  
Constructors should only call non-overridable methods
541
            this.setIcon(icon);
Remove this call from a constructor to the overridable "setIcon" method.     NEW     squid:S1699  
Constructors should only call non-overridable methods
542
            this.setPackageName(packageName);
Remove this call from a constructor to the overridable "setPackageName" method.     NEW     squid:S1699  
Constructors should only call non-overridable methods
543
            this.setPackagePath(packagePath);
Remove this call from a constructor to the overridable "setPackagePath" method.     NEW     squid:S1699  
Constructors should only call non-overridable methods
544
            this.setVersionName(versionName);
Remove this call from a constructor to the overridable "setVersionName" method.     NEW     squid:S1699  
Constructors should only call non-overridable methods
545
            this.setVersionCode(versionCode);
Remove this call from a constructor to the overridable "setVersionCode" method.     NEW     squid:S1699  
Constructors should only call non-overridable methods
546
            this.setSystem(isSystem);
Remove this call from a constructor to the overridable "setSystem" method.     NEW     squid:S1699  
Constructors should only call non-overridable methods
547
        }
548

                  
549
//        @Override
550
//        public String toString() {
This block of commented-out lines of code should be removed.     NEW     squid:CommentedOutCodeLine  
Sections of code should not be "commented out"
551
//            return getName() + "\n"
552
//                    + getIcon() + "\n"
556
//                    + getVersionCode() + "\n"
557
//                    + isSystem() + "\n"
558
//        }
This block of commented-out lines of code should be removed.     NEW     squid:CommentedOutCodeLine  
Sections of code should not be "commented out"
559
    }
560

                  
566
     * @return 当前应用的AppInfo
567
     */
568
    public static AppInfo getAppInfo(Context context) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
569
        return getAppInfo(context, context.getPackageName());
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
570
    }
571

                  
577
     * @return 当前应用的AppInfo
578
     */
579
    public static AppInfo getAppInfo(Context context, String packageName) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document the parameter(s): packageName     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
580
        try {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
581
            PackageManager pm = context.getPackageManager();
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
582
            PackageInfo pi = pm.getPackageInfo(packageName, 0);
583
            return getBean(pm, pi);
584
        } catch (PackageManager.NameNotFoundException e) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "catch" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
Either log or rethrow this exception.     NEW     squid:S1166  
Exception handlers should preserve the original exceptions
585
            e.printStackTrace();
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
586
            return null;
587
        }
595
     * @return AppInfo类
596
     */
597
    private static AppInfo getBean(PackageManager pm, PackageInfo pi) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
598
        if (pm == null || pi == null) return null;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
599
        ApplicationInfo ai = pi.applicationInfo;
600
        String name = ai.loadLabel(pm).toString();
616
     * @return 所有已安装的AppInfo列表
617
     */
618
    public static List<AppInfo> getAppsInfo(Context context) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
619
        List<AppInfo> list = new ArrayList<>();
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
620
        PackageManager pm = context.getPackageManager();
621
        // 获取系统中安装的所有软件信息
622
        List<PackageInfo> installedPackages = pm.getInstalledPackages(0);
623
        for (PackageInfo pi : installedPackages) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
624
            AppInfo ai = getBean(pm, pi);
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
625
            if (ai == null) continue;
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
626
            list.add(ai);
627
        }
635
     * @param dirPaths 目录路径
636
     */
637
    public static boolean cleanAppData(Context context, String... dirPaths) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Do not use varargs.     NEW     squid:S923  
Functions should not be defined with a variable number of arguments
Document this method return value.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
638
        File[] dirs = new File[dirPaths.length];
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
639
        int i = 0;
640
        for (String dirPath : dirPaths) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
641
            dirs[i++] = new File(dirPath);
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Extract this increment or decrement operator into a dedicated statement.     NEW     squid:S881  
Increment (++) and decrement (--) operators should not be used in a method call or mixed with other operators in an expression
642
        }
643
        return cleanAppData(context, dirs);
650
     * @param dirs    目录
651
     */
652
    public static boolean cleanAppData(Context context, File... dirs) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Do not use varargs.     NEW     squid:S923  
Functions should not be defined with a variable number of arguments
Document this method return value.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
653
        boolean isSuccess = CleanUtils.cleanInternalCache(context);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
654
        isSuccess &= CleanUtils.cleanInternalDbs(context);
655
        isSuccess &= CleanUtils.cleanInternalSP(context);
656
        isSuccess &= CleanUtils.cleanInternalFiles(context);
657
        isSuccess &= CleanUtils.cleanExternalCache(context);
658
        for (File dir : dirs) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
659
            isSuccess &= CleanUtils.cleanCustomCache(dir);
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
660
        }
661
        return isSuccess;
42
New issues
Add or update the header of this file.     NEW     squid:S1451
Copyright and license headers should be defined
1
package com.blankj.utilcode.utils;
2

                  
18
 * </pre>
19
 */
20
public class BarUtils {
Make this class "final" or add a public constructor.     NEW     squid:S2974  
Classes without "public" constructors should be "final"
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
21
    private BarUtils() {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Make this line start at column 3.     NEW     squid:IndentationCheck  
Source code should be indented consistently
22
        throw new UnsupportedOperationException("u can't instantiate me...");
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
23
    }
24

                  
32
     * @param activity activity
33
     */
34
    public static void setTransparentStatusBar(Activity activity) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
35
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
36
            //透明状态栏
37
            activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
38
            //透明导航栏
39
            activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
51
     * @param activity activity
52
     */
53
    public static void hideStatusBar(Activity activity) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
54
        activity.requestWindowFeature(Window.FEATURE_NO_TITLE);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
55
        activity.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
56
                WindowManager.LayoutParams.FLAG_FULLSCREEN);
63
     * @return 状态栏高度
64
     */
65
    public static int getStatusBarHeight(Context context) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
66
        int result = 0;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
67
        int resourceId = context.getResources()
68
                .getIdentifier("status_bar_height", "dimen", "android");
69
        if (resourceId > 0) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
70
            result = context.getResources().getDimensionPixelSize(resourceId);
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
71
        }
72
        return result;
79
     * @return {@code true}: 存在<br>{@code false}: 不存在
80
     */
81
    public static boolean isStatusBarExists(Activity activity) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
82
        WindowManager.LayoutParams params = activity.getWindow().getAttributes();
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
83
        return (params.flags & WindowManager.LayoutParams.FLAG_FULLSCREEN) != WindowManager.LayoutParams.FLAG_FULLSCREEN;
Split this 121 characters long line (which is greater than 120 authorized).     NEW     squid:S00103  
Lines should not be too long
84
    }
85

                  
90
     * @return ActionBar高度
91
     */
92
    public static int getActionBarHeight(Activity activity) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
93
        TypedValue tv = new TypedValue();
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
94
        if (activity.getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true)) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
95
            return TypedValue.complexToDimensionPixelSize(tv.data, activity.getResources().getDisplayMetrics());
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
96
        }
97
        return 0;
105
     * @param isSettingPanel {@code true}: 打开设置<br>{@code false}: 打开通知
106
     */
107
    public static void showNotificationBar(Context context, boolean isSettingPanel) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
108
        String methodName = (Build.VERSION.SDK_INT <= 16) ? "expand"
Convert this usage of the ternary operator to an "if"/"else" structure.     NEW     squid:S1774  
The ternary operator should not be used
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Assign this magic number 16 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
109
                : (isSettingPanel ? "expandSettingsPanel" : "expandNotificationsPanel");
Convert this usage of the ternary operator to an "if"/"else" structure.     NEW     squid:S1774  
The ternary operator should not be used
110
        invokePanels(context, methodName);
111
    }
117
     * @param context 上下文
118
     */
119
    public static void hideNotificationBar(Context context) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
120
        String methodName = (Build.VERSION.SDK_INT <= 16) ? "collapse" : "collapsePanels";
Convert this usage of the ternary operator to an "if"/"else" structure.     NEW     squid:S1774  
The ternary operator should not be used
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Assign this magic number 16 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
121
        invokePanels(context, methodName);
122
    }
128
     * @param methodName 方法名
129
     */
130
    private static void invokePanels(Context context, String methodName) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
131
        try {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
132
            Object service = context.getSystemService("statusbar");
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
133
            Class<?> statusBarManager = Class.forName("android.app.StatusBarManager");
Remove this use of dynamic class loading.     NEW     squid:S2658  
Classes should not be loaded dynamically
134
            Method expand = statusBarManager.getMethod(methodName);
135
            expand.invoke(service);
136
        } catch (Exception e) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "catch" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
Either log or rethrow this exception.     NEW     squid:S1166  
Exception handlers should preserve the original exceptions
137
            e.printStackTrace();
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Use a logger to log this exception.     NEW     squid:S1148  
Throwable.printStackTrace(...) should not be called
138
        }
139
    }
93
New issues
Add or update the header of this file.     NEW     squid:S1451
Copyright and license headers should be defined
1
package com.blankj.utilcode.utils;
2

                  
21
 * </pre>
22
 */
23
public class CameraUtils {
Make this class "final" or add a public constructor.     NEW     squid:S2974  
Classes without "public" constructors should be "final"
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
24

                  
25
    private CameraUtils() {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Make this line start at column 3.     NEW     squid:IndentationCheck  
Source code should be indented consistently
26
        throw new UnsupportedOperationException("u can't instantiate me...");
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
27
    }
28

                  
30
     * 获取打开照程序界面的Intent
31
     */
32
    public static Intent getOpenCameraIntent() {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
33
        return new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
34
    }
35

                  
37
     * 获取跳转至相册选择界面的Intent
38
     */
39
    public static Intent getImagePickerIntent() {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
40
        Intent intent = new Intent(Intent.ACTION_PICK, null);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
41
        return intent.setDataAndType(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, "image/*");
Define a constant instead of duplicating this literal "image/*" 3 times.     NEW     squid:S1192  
String literals should not be duplicated
42
    }
43

                  
45
     * 获取[跳转至相册选择界面,并跳转至裁剪界面,默认可缩放裁剪区域]的Intent
46
     */
47
    public static Intent getImagePickerIntent(int outputX, int outputY, Uri fromFileURI,
Document the parameter(s): outputX, outputY, fromFileURI, saveFileURI     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
Document this method return value.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
48
                                              Uri saveFileURI) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
49
        return getImagePickerIntent(1, 1, outputX, outputY, true, fromFileURI, saveFileURI);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
50
    }
51

                  
53
     * 获取[跳转至相册选择界面,并跳转至裁剪界面,默认可缩放裁剪区域]的Intent
54
     */
55
    public static Intent getImagePickerIntent(int aspectX, int aspectY, int outputX, int outputY, Uri fromFileURI,
Document the parameter(s): aspectX, aspectY, outputX, outputY, fromFileURI, saveFileURI     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
Document this method return value.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
56
                                              Uri saveFileURI) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
57
        return getImagePickerIntent(aspectX, aspectY, outputX, outputY, true, fromFileURI, saveFileURI);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
58
    }
59

                  
69
     * @param saveFileURI 输出文件路径URI
70
     */
71
    public static Intent getImagePickerIntent(int aspectX, int aspectY, int outputX, int outputY, boolean canScale,
Document this method return value.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
72
                                              Uri fromFileURI, Uri saveFileURI) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
73
        Intent intent = new Intent(Intent.ACTION_PICK);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
74
        intent.setDataAndType(fromFileURI, "image/*");
75
        intent.putExtra("crop", "true");
76
        intent.putExtra("aspectX", aspectX <= 0 ? 1 : aspectX);
Convert this usage of the ternary operator to an "if"/"else" structure.     NEW     squid:S1774  
The ternary operator should not be used
77
        intent.putExtra("aspectY", aspectY <= 0 ? 1 : aspectY);
Convert this usage of the ternary operator to an "if"/"else" structure.     NEW     squid:S1774  
The ternary operator should not be used
78
        intent.putExtra("outputX", outputX);
79
        intent.putExtra("outputY", outputY);
91
     * 获取[跳转至相册选择界面,并跳转至裁剪界面,默认可缩放裁剪区域]的Intent
92
     */
93
    public static Intent getCameraIntent(Uri saveFileURI) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document the parameter(s): saveFileURI     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
Document this method return value.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
94
        Intent mIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
95
        return mIntent.putExtra(MediaStore.EXTRA_OUTPUT, saveFileURI);
96
    }
99
     * 获取[跳转至裁剪界面,默认可缩放]的Intent
100
     */
101
    public static Intent getCropImageIntent(int outputX, int outputY, Uri fromFileURI,
Document the parameter(s): outputX, outputY, fromFileURI, saveFileURI     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
Document this method return value.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
102
                                            Uri saveFileURI) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
103
        return getCropImageIntent(1, 1, outputX, outputY, true, fromFileURI, saveFileURI);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
104
    }
105

                  
107
     * 获取[跳转至裁剪界面,默认可缩放]的Intent
108
     */
109
    public static Intent getCropImageIntent(int aspectX, int aspectY, int outputX, int outputY, Uri fromFileURI,
Document the parameter(s): aspectX, aspectY, outputX, outputY, fromFileURI, saveFileURI     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
Document this method return value.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
110
                                            Uri saveFileURI) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
111
        return getCropImageIntent(aspectX, aspectY, outputX, outputY, true, fromFileURI, saveFileURI);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
112
    }
113

                  
116
     * 获取[跳转至裁剪界面]的Intent
117
     */
118
    public static Intent getCropImageIntent(int aspectX, int aspectY, int outputX, int outputY, boolean canScale,
Document the parameter(s): aspectX, aspectY, outputX, outputY, canScale, fromFileURI, saveFileURI     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
Document this method return value.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
119
                                            Uri fromFileURI, Uri saveFileURI) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
120
        Intent intent = new Intent("com.android.camera.action.CROP");
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
121
        intent.setDataAndType(fromFileURI, "image/*");
122
        intent.putExtra("crop", "true");
123
        // X方向上的比例
124
        intent.putExtra("aspectX", aspectX <= 0 ? 1 : aspectX);
Convert this usage of the ternary operator to an "if"/"else" structure.     NEW     squid:S1774  
The ternary operator should not be used
125
        // Y方向上的比例
126
        intent.putExtra("aspectY", aspectY <= 0 ? 1 : aspectY);
Convert this usage of the ternary operator to an "if"/"else" structure.     NEW     squid:S1774  
The ternary operator should not be used
127
        intent.putExtra("outputX", outputX);
128
        intent.putExtra("outputY", outputY);
147
     * @return bitmap
148
     */
149
    public static Bitmap getChoosedImage(Activity context, Intent data) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
150
        if (data == null) return null;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
151
        Bitmap bm = null;
152
        ContentResolver cr = context.getContentResolver();
153
        Uri originalUri = data.getData();
154
        try {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
155
            bm = MediaStore.Images.Media.getBitmap(cr, originalUri);
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
156
        } catch (IOException e) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "catch" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
Either log or rethrow this exception.     NEW     squid:S1166  
Exception handlers should preserve the original exceptions
157
            e.printStackTrace();
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Use a logger to log this exception.     NEW     squid:S1148  
Throwable.printStackTrace(...) should not be called
158
        }
159
        return bm;
167
     * @return
168
     */
169
    public static String getChoosedImagePath(Activity context, Intent data) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
170
        if (data == null) return null;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
171
        String path = "";
Move the declaration of "path" closer to the code that uses it.     NEW     squid:S1941  
Variables should not be declared before they are relevant
172
        ContentResolver resolver = context.getContentResolver();
Move the declaration of "resolver" closer to the code that uses it.     NEW     squid:S1941  
Variables should not be declared before they are relevant
173
        Uri originalUri = data.getData();
174
        if (null == originalUri) return null;
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
175
        String[] projection = {MediaStore.Images.Media.DATA};
176
        Cursor cursor = resolver.query(originalUri, projection, null, null, null);
177
        if (null != cursor) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
178
            try {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
179
                int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
Make this line start at column 9.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Rename this local variable name to match the regular expression '^[a-z][a-zA-Z0-9]*$'.     NEW     squid:S00117  
Local variable and method parameter names should comply with a naming convention
180
                cursor.moveToFirst();
181
                path = cursor.getString(column_index);
182
            } catch (IllegalArgumentException e) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "catch" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
Either log or rethrow this exception.     NEW     squid:S1166  
Exception handlers should preserve the original exceptions
183
                e.printStackTrace();
Make this line start at column 9.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Use a logger to log this exception.     NEW     squid:S1148  
Throwable.printStackTrace(...) should not be called
184
            } finally {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "finally" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
185
                try {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Make this line start at column 9.     NEW     squid:IndentationCheck  
Source code should be indented consistently
186
                    if (!cursor.isClosed()) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Make this line start at column 11.     NEW     squid:IndentationCheck  
Source code should be indented consistently
187
                        cursor.close();
Make this line start at column 13.     NEW     squid:IndentationCheck  
Source code should be indented consistently
188
                    }
189
                } catch (Exception e) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "catch" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
Either log or rethrow this exception.     NEW     squid:S1166  
Exception handlers should preserve the original exceptions
190
                    e.printStackTrace();
Make this line start at column 11.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Use a logger to log this exception.     NEW     squid:S1148  
Throwable.printStackTrace(...) should not be called
191
                }
192
            }
193
        }
194
        return StringUtils.isEmpty(path) ? originalUri.getPath() : null;
Convert this usage of the ternary operator to an "if"/"else" structure.     NEW     squid:S1774  
The ternary operator should not be used
195
    }
196

                  
202
     * @return 文件
203
     */
204
    public static File getTakePictureFile(Intent data, String filePath) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Reduce the number of returns of this method 4, down to the maximum allowed 3.     NEW     squid:S1142  
Methods should not have too many return statements
205
        if (data == null) return null;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
206
        Bundle extras = data.getExtras();
207
        if (extras == null) return null;
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
208
        Bitmap photo = extras.getParcelable("data");
209
        File file = new File(filePath);
210
        if (ImageUtils.save(photo, file, Bitmap.CompressFormat.JPEG)) return file;
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
211
        return null;
212
    }
22
New issues
Add or update the header of this file.     NEW     squid:S1451
Copyright and license headers should be defined
1
package com.blankj.utilcode.utils;
2

                  
13
 * </pre>
14
 */
15
public class CleanUtils {
Make this class "final" or add a public constructor.     NEW     squid:S2974  
Classes without "public" constructors should be "final"
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
16

                  
17
    private CleanUtils() {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Make this line start at column 3.     NEW     squid:IndentationCheck  
Source code should be indented consistently
18
        throw new UnsupportedOperationException("u can't instantiate me...");
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
19
    }
20

                  
26
     * @return {@code true}: 清除成功<br>{@code false}: 清除失败
27
     */
28
    public static boolean cleanInternalCache(Context context) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
29
        return FileUtils.deleteFilesInDir(context.getCacheDir());
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
30
    }
31

                  
37
     * @return {@code true}: 清除成功<br>{@code false}: 清除失败
38
     */
39
    public static boolean cleanInternalFiles(Context context) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
40
        return FileUtils.deleteFilesInDir(context.getFilesDir());
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
41
    }
42

                  
48
     * @return {@code true}: 清除成功<br>{@code false}: 清除失败
49
     */
50
    public static boolean cleanInternalDbs(Context context) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
51
        return FileUtils.deleteFilesInDir(context.getFilesDir().getParent() + File.separator + "databases");
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
52
    }
53

                  
60
     * @return {@code true}: 清除成功<br>{@code false}: 清除失败
61
     */
62
    public static boolean cleanInternalDbByName(Context context, String dbName) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
63
        return context.deleteDatabase(dbName);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
64
    }
65

                  
71
     * @return {@code true}: 清除成功<br>{@code false}: 清除失败
72
     */
73
    public static boolean cleanInternalSP(Context context) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
74
        return FileUtils.deleteFilesInDir(context.getFilesDir().getParent() + File.separator + "shared_prefs");
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
75
    }
76

                  
82
     * @return {@code true}: 清除成功<br>{@code false}: 清除失败
83
     */
84
    public static boolean cleanExternalCache(Context context) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
85
        return SDCardUtils.isSDCardEnable() && FileUtils.deleteFilesInDir(context.getExternalCacheDir());
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
86
    }
87

                  
92
     * @return {@code true}: 清除成功<br>{@code false}: 清除失败
93
     */
94
    public static boolean cleanCustomCache(String dirPath) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
95
        return FileUtils.deleteFilesInDir(dirPath);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
96
    }
97

                  
102
     * @return {@code true}: 清除成功<br>{@code false}: 清除失败
103
     */
104
    public static boolean cleanCustomCache(File dir) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
105
        return FileUtils.deleteFilesInDir(dir);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
106
    }
107
}
24
New issues
Add or update the header of this file.     NEW     squid:S1451
Copyright and license headers should be defined
1
package com.blankj.utilcode.utils;
2

                  
15
 * </pre>
16
 */
17
public class ClipboardUtils {
Make this class "final" or add a public constructor.     NEW     squid:S2974  
Classes without "public" constructors should be "final"
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
18

                  
19
    private ClipboardUtils() {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Make this line start at column 3.     NEW     squid:IndentationCheck  
Source code should be indented consistently
20
        throw new UnsupportedOperationException("u can't instantiate me...");
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
21
    }
22

                  
27
     * @param text    文本
28
     */
29
    public static void copyText(Context context, CharSequence text) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
30
        ClipboardManager clipboard = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
31
        clipboard.setPrimaryClip(ClipData.newPlainText("text", text));
32
    }
38
     * @return 剪贴板的文本
39
     */
40
    public static CharSequence getText(Context context) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
41
        ClipboardManager clipboard = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
42
        ClipData clip = clipboard.getPrimaryClip();
43
        if (clip != null && clip.getItemCount() > 0) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
44
            return clip.getItemAt(0).coerceToText(context);
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
45
        }
46
        return null;
53
     * @param uri     uri
54
     */
55
    public static void copyUri(Context context, Uri uri) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
56
        ClipboardManager clipboard = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
57
        clipboard.setPrimaryClip(ClipData.newUri(context.getContentResolver(), "uri", uri));
58
    }
64
     * @return 剪贴板的uri
65
     */
66
    public static Uri getUri(Context context) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
67
        ClipboardManager clipboard = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
68
        ClipData clip = clipboard.getPrimaryClip();
69
        if (clip != null && clip.getItemCount() > 0) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
70
            return clip.getItemAt(0).getUri();
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
71
        }
72
        return null;
79
     * @param intent  意图
80
     */
81
    public static void copyIntent(Context context, Intent intent) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
82
        ClipboardManager clipboard = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
83
        clipboard.setPrimaryClip(ClipData.newIntent("intent", intent));
84
    }
90
     * @return 剪贴板的意图
91
     */
92
    public static Intent getIntent(Context context) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
93
        ClipboardManager clipboard = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
94
        ClipData clip = clipboard.getPrimaryClip();
95
        if (clip != null && clip.getItemCount() > 0) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
96
            return clip.getItemAt(0).getIntent();
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
97
        }
98
        return null;
41
New issues
Add or update the header of this file.     NEW     squid:S1451
Copyright and license headers should be defined
Add a new line at the end of this file.     NEW     squid:S00113
Files should contain an empty new line at the end
1
package com.blankj.utilcode.utils;
2

                  
9
 * </pre>
10
 */
11
public class ConstUtils {
Make this class "final" or add a public constructor.     NEW     squid:S2974  
Classes without "public" constructors should be "final"
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
12

                  
13
    private ConstUtils() {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Make this line start at column 3.     NEW     squid:IndentationCheck  
Source code should be indented consistently
14
        throw new UnsupportedOperationException("u can't instantiate me...");
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
15
    }
16

                  
19
     * Byte与Byte的倍数
20
     */
21
    public static final int BYTE = 1;
Move this variable to comply with Java Code Conventions.     NEW     squid:S1213  
The members of an interface declaration or class should appear in a pre-defined order
22
    /**
23
     * KB与Byte的倍数
24
     */
25
    public static final int KB = 1024;
Move this variable to comply with Java Code Conventions.     NEW     squid:S1213  
The members of an interface declaration or class should appear in a pre-defined order
26
    /**
27
     * MB与Byte的倍数
28
     */
29
    public static final int MB = 1048576;
Move this variable to comply with Java Code Conventions.     NEW     squid:S1213  
The members of an interface declaration or class should appear in a pre-defined order
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
30
    /**
31
     * GB与Byte的倍数
32
     */
33
    public static final int GB = 1073741824;
Move this variable to comply with Java Code Conventions.     NEW     squid:S1213  
The members of an interface declaration or class should appear in a pre-defined order
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
34

                  
35
    public enum MemoryUnit {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Make this line start at column 3.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Document this public enum.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
36
        BYTE,
37
        KB,
44
     * 毫秒与毫秒的倍数
45
     */
46
    public static final int MSEC = 1;
Move this variable to comply with Java Code Conventions.     NEW     squid:S1213  
The members of an interface declaration or class should appear in a pre-defined order
47
    /**
48
     * 秒与毫秒的倍数
49
     */
50
    public static final int SEC = 1000;
Move this variable to comply with Java Code Conventions.     NEW     squid:S1213  
The members of an interface declaration or class should appear in a pre-defined order
51
    /**
52
     * 分与毫秒的倍数
53
     */
54
    public static final int MIN = 60000;
Move this variable to comply with Java Code Conventions.     NEW     squid:S1213  
The members of an interface declaration or class should appear in a pre-defined order
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
55
    /**
56
     * 时与毫秒的倍数
57
     */
58
    public static final int HOUR = 3600000;
Move this variable to comply with Java Code Conventions.     NEW     squid:S1213  
The members of an interface declaration or class should appear in a pre-defined order
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
59
    /**
60
     * 天与毫秒的倍数
61
     */
62
    public static final int DAY = 86400000;
Move this variable to comply with Java Code Conventions.     NEW     squid:S1213  
The members of an interface declaration or class should appear in a pre-defined order
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
63

                  
64
    public enum TimeUnit {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Make this line start at column 3.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Document this public enum.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
65
        MSEC,
66
        SEC,
74
     * 正则:手机号(简单)
75
     */
76
    public static final String REGEX_MOBILE_SIMPLE = "^[1]\\d{10}$";
Move this variable to comply with Java Code Conventions.     NEW     squid:S1213  
The members of an interface declaration or class should appear in a pre-defined order
77
    /**
78
     * 正则:手机号(精确)
83
     * <p>虚拟运营商:170</p>
84
     */
85
    public static final String REGEX_MOBILE_EXACT = "^((13[0-9])|(14[5,7])|(15[0-3,5-9])|(17[0,3,5-8])|(18[0-9])|(147))\\d{8}$";
Move this variable to comply with Java Code Conventions.     NEW     squid:S1213  
The members of an interface declaration or class should appear in a pre-defined order
Split this 128 characters long line (which is greater than 120 authorized).     NEW     squid:S00103  
Lines should not be too long
86
    /**
87
     * 正则:电话号码
88
     */
89
    public static final String REGEX_TEL = "^0\\d{2,3}[- ]?\\d{7,8}";
Move this variable to comply with Java Code Conventions.     NEW     squid:S1213  
The members of an interface declaration or class should appear in a pre-defined order
90
    /**
91
     * 正则:身份证号码15位
92
     */
93
    public static final String REGEX_IDCARD15 = "^[1-9]\\d{7}((0\\d)|(1[0-2]))(([0|1|2]\\d)|3[0-1])\\d{3}$";
Move this variable to comply with Java Code Conventions.     NEW     squid:S1213  
The members of an interface declaration or class should appear in a pre-defined order
94
    /**
95
     * 正则:身份证号码18位
96
     */
97
    public static final String REGEX_IDCARD18 = "^[1-9]\\d{5}[1-9]\\d{3}((0\\d)|(1[0-2]))(([0|1|2]\\d)|3[0-1])\\d{3}([0-9Xx])$";
Move this variable to comply with Java Code Conventions.     NEW     squid:S1213  
The members of an interface declaration or class should appear in a pre-defined order
Split this 128 characters long line (which is greater than 120 authorized).     NEW     squid:S00103  
Lines should not be too long
98
    /**
99
     * 正则:邮箱
100
     */
101
    public static final String REGEX_EMAIL = "^\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*$";
Move this variable to comply with Java Code Conventions.     NEW     squid:S1213  
The members of an interface declaration or class should appear in a pre-defined order
102
    /**
103
     * 正则:URL
104
     */
105
    public static final String REGEX_URL = "http(s)?://([\\w-]+\\.)+[\\w-]+(/[\\w-./?%&=]*)?";
Move this variable to comply with Java Code Conventions.     NEW     squid:S1213  
The members of an interface declaration or class should appear in a pre-defined order
106
    /**
107
     * 正则:汉字
108
     */
109
    public static final String REGEX_CHZ = "^[\\u4e00-\\u9fa5]+$";
Move this variable to comply with Java Code Conventions.     NEW     squid:S1213  
The members of an interface declaration or class should appear in a pre-defined order
110
    /**
111
     * 正则:用户名,取值范围为a-z,A-Z,0-9,"_",汉字,不能以"_"结尾,用户名必须是6-20位
112
     */
113
    public static final String REGEX_USERNAME = "^[\\w\\u4e00-\\u9fa5]{6,20}(?<!_)$";
Move this variable to comply with Java Code Conventions.     NEW     squid:S1213  
The members of an interface declaration or class should appear in a pre-defined order
114
    /**
115
     * 正则:yyyy-MM-dd格式的日期校验,已考虑平闰年
116
     */
117
    public static final String REGEX_DATE = "^(?:(?!0000)[0-9]{4}-(?:(?:0[1-9]|1[0-2])-(?:0[1-9]|1[0-9]|2[0-8])|(?:0[13-9]|1[0-2])-(?:29|30)|(?:0[13578]|1[02])-31)|(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:0[48]|[2468][048]|[13579][26])00)-02-29)$";
Move this variable to comply with Java Code Conventions.     NEW     squid:S1213  
The members of an interface declaration or class should appear in a pre-defined order
Split this 255 characters long line (which is greater than 120 authorized).     NEW     squid:S00103  
Lines should not be too long
118
    /**
119
     * 正则:IP地址
120
     */
121
    public static final String REGEX_IP = "((2[0-4]\\d|25[0-5]|[01]?\\d\\d?)\\.){3}(2[0-4]\\d|25[0-5]|[01]?\\d\\d?)";
Move this variable to comply with Java Code Conventions.     NEW     squid:S1213  
The members of an interface declaration or class should appear in a pre-defined order
122
}
229
New issues
Add or update the header of this file.     NEW     squid:S1451
Copyright and license headers should be defined
Replace all tab characters in this file by sequences of white-spaces.     NEW     squid:S00105
Tabulation characters should not be used
1
package com.blankj.utilcode.utils;
2

                  
32
 * </pre>
33
 */
34
public class ConvertUtils {
Make this class "final" or add a public constructor.     NEW     squid:S2974  
Classes without "public" constructors should be "final"
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
35

                  
36
    private ConvertUtils() {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Make this line start at column 3.     NEW     squid:IndentationCheck  
Source code should be indented consistently
37
        throw new UnsupportedOperationException("u can't instantiate me...");
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
38
    }
39

                  
40
    static final char hexDigits[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
Move the array designator from the variable to the type.     NEW     squid:S1197  
Array designators "[]" should be on the type, not the variable
Explicitly declare the visibility for "hexDigits".     NEW     squid:S2039  
Member variable visibility should be specified
Move this variable to comply with Java Code Conventions.     NEW     squid:S1213  
The members of an interface declaration or class should appear in a pre-defined order
41

                  
42
    /**
48
     * @return 16进制大写字符串
49
     */
50
    public static String bytes2HexString(byte[] bytes) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
51
        char[] ret = new char[bytes.length << 1];
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
52
        for (int i = 0, j = 0; i < bytes.length; i++) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
53
            ret[j++] = hexDigits[bytes[i] >>> 4 & 0x0f];
Add parentheses to make the operator precedence explicit.     NEW     squid:S864  
Limited dependence should be placed on operator precedence rules in expressions
Refactor the code in order to not assign to this loop counter from within the loop body.     NEW     squid:ForLoopCounterChangedCheck  
"for" loop stop conditions should be invariant
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Assign this magic number 4 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Extract this increment or decrement operator into a dedicated statement.     NEW     squid:S881  
Increment (++) and decrement (--) operators should not be used in a method call or mixed with other operators in an expression
54
            ret[j++] = hexDigits[bytes[i] & 0x0f];
Refactor the code in order to not assign to this loop counter from within the loop body.     NEW     squid:ForLoopCounterChangedCheck  
"for" loop stop conditions should be invariant
Extract this increment or decrement operator into a dedicated statement.     NEW     squid:S881  
Increment (++) and decrement (--) operators should not be used in a method call or mixed with other operators in an expression
55
        }
56
        return new String(ret);
65
     * @return 字节数组
66
     */
67
    public static byte[] hexString2Bytes(String hexString) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
68
        int len = hexString.length();
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
69
        if(len % 2 !=0){
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Assign this magic number 2 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
70
            hexString = "0" + hexString;
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Introduce a new variable instead of reusing the parameter "hexString".     NEW     squid:S1226  
Method parameters, caught exceptions and foreach variables should not be reassigned
71
            len = len + 1;
72
        }
73
        char[] hexBytes = hexString.toUpperCase().toCharArray();
Define the locale to be used in this String operation.     NEW     squid:S1449  
Locale should be used in String operations
74
        byte[] ret = new byte[len >> 1];
75
        for (int i = 0; i < len; i += 2) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Assign this magic number 2 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
76
            ret[i >> 1] = (byte) (hex2Dec(hexBytes[i]) << 4 | hex2Dec(hexBytes[i + 1]));
Add parentheses to make the operator precedence explicit.     NEW     squid:S864  
Limited dependence should be placed on operator precedence rules in expressions
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Assign this magic number 4 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
77
        }
78
        return ret;
85
     * @return 0..15
86
     */
87
    private static int hex2Dec(char hexChar) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
88
	String myTimeString = "test error";
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Remove this unused "myTimeString" local variable.     NEW     squid:S1481  
Unused local variables should be removed
Remove this useless assignment to local variable "myTimeString".     NEW     squid:S1854  
Dead stores should be removed
89
        if (hexChar >= '0' && hexChar <= '9') {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
90
            return hexChar - '0';
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
91
        } else if (hexChar >= 'A' && hexChar <= 'F') {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "else" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
92
            return hexChar - 'A' + 10;
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Assign this magic number 10 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
93
        } else {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "else" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
94
            throw new IllegalArgumentException();
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
95
        }
96
    }
102
     * @return 字节数组
103
     */
104
    public static byte[] chars2Bytes(char[] chars) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
105
        int len = chars.length;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
106
        byte[] bytes = new byte[len];
107
        for (int i = 0; i < len; i++) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
108
            bytes[i] = (byte) (chars[i]);
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
109
        }
110
        return bytes;
117
     * @return 字符数组
118
     */
119
    public static char[] bytes2Chars(byte[] bytes) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
120
        int len = bytes.length;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
121
        char[] chars = new char[len];
122
        for (int i = 0; i < len; i++) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
123
            chars[i] = (char) (bytes[i] & 0xff);
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
124
        }
125
        return chars;
138
     * @return 以unit为单位的size
139
     */
140
    public static double byte2Size(long byteNum, ConstUtils.MemoryUnit unit) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Reduce the number of returns of this method 5, down to the maximum allowed 3.     NEW     squid:S1142  
Methods should not have too many return statements
The Cyclomatic Complexity of this method "byte2Size" is 11 which is greater than 10 authorized.     NEW     squid:MethodCyclomaticComplexity  
Methods should not be too complex
141
        if (byteNum < 0) return -1;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
142
        switch (unit) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
143
            default:
Move this default to the end of the switch.     NEW     squid:SwitchLastCaseIsDefaultCheck  
"switch" statements should end with "default" clauses
144
            case BYTE:
145
                return (double) byteNum / BYTE;
Make this line start at column 9.     NEW     squid:IndentationCheck  
Source code should be indented consistently
146
            case KB:
147
                return (double) byteNum / KB;
Make this line start at column 9.     NEW     squid:IndentationCheck  
Source code should be indented consistently
148
            case MB:
149
                return (double) byteNum / MB;
Make this line start at column 9.     NEW     squid:IndentationCheck  
Source code should be indented consistently
150
            case GB:
151
                return (double) byteNum / GB;
Make this line start at column 9.     NEW     squid:IndentationCheck  
Source code should be indented consistently
152
        }
153
    }
165
     * @return 字节数
166
     */
167
    public static long size2Byte(long size, ConstUtils.MemoryUnit unit) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Reduce the number of returns of this method 5, down to the maximum allowed 3.     NEW     squid:S1142  
Methods should not have too many return statements
The Cyclomatic Complexity of this method "size2Byte" is 11 which is greater than 10 authorized.     NEW     squid:MethodCyclomaticComplexity  
Methods should not be too complex
168
        if (size < 0) return -1;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
169
        switch (unit) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
170
            default:
Move this default to the end of the switch.     NEW     squid:SwitchLastCaseIsDefaultCheck  
"switch" statements should end with "default" clauses
171
            case BYTE:
172
                return size * BYTE;
Make this line start at column 9.     NEW     squid:IndentationCheck  
Source code should be indented consistently
173
            case KB:
174
                return size * KB;
Make this line start at column 9.     NEW     squid:IndentationCheck  
Source code should be indented consistently
175
            case MB:
176
                return size * MB;
Make this line start at column 9.     NEW     squid:IndentationCheck  
Source code should be indented consistently
177
            case GB:
178
                return size * GB;
Make this line start at column 9.     NEW     squid:IndentationCheck  
Source code should be indented consistently
179
        }
180
    }
187
     * @return 1...1024 unit
188
     */
189
    public static String byte2FitSize(long byteNum) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Reduce the number of returns of this method 5, down to the maximum allowed 3.     NEW     squid:S1142  
Methods should not have too many return statements
190
        if (byteNum < 0) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
191
            return "shouldn't be less than zero!";
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
192
        } else if (byteNum < KB) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "else" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
193
            return String.format(Locale.getDefault(), "%.3fB", (double) byteNum);
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
194
        } else if (byteNum < MB) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "else" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
195
            return String.format(Locale.getDefault(), "%.3fKB", (double) byteNum / KB);
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
196
        } else if (byteNum < GB) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "else" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
197
            return String.format(Locale.getDefault(), "%.3fMB", (double) byteNum / MB);
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
198
        } else {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "else" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
199
            return String.format(Locale.getDefault(), "%.3fGB", (double) byteNum / GB);
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
200
        }
201
    }
207
     * @return outputStream子类
208
     */
209
    public static ByteArrayOutputStream input2OutputStream(InputStream is) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
210
        if (is == null) return null;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
211
        try {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Change this "try" to a try-with-resources. (sonar.java.source not set. Assuming 7 or greater.)     NEW     squid:S2093  
Try-with-resources should be used
212
            ByteArrayOutputStream os = new ByteArrayOutputStream();
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
213
            byte[] b = new byte[KB];
214
            int len;
215
            while ((len = is.read(b, 0, KB)) != -1) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
216
                os.write(b, 0, len);
Make this line start at column 9.     NEW     squid:IndentationCheck  
Source code should be indented consistently
217
            }
218
            return os;
219
        } catch (IOException e) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "catch" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
Either log or rethrow this exception.     NEW     squid:S1166  
Exception handlers should preserve the original exceptions
220
            e.printStackTrace();
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Use a logger to log this exception.     NEW     squid:S1148  
Throwable.printStackTrace(...) should not be called
221
            return null;
222
        } finally {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "finally" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
223
            FileUtils.closeIO(is);
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
224
        }
225
    }
231
     * @return inputStream子类
232
     */
233
    public ByteArrayInputStream output2InputStream(OutputStream out) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
234
        if (out == null) return null;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
235
        return new ByteArrayInputStream(((ByteArrayOutputStream) out).toByteArray());
236
    }
242
     * @return 字节数组
243
     */
244
    public static byte[] inputStream2Bytes(InputStream is) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
245
        return input2OutputStream(is).toByteArray();
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
246
    }
247

                  
252
     * @return 输入流
253
     */
254
    public static InputStream bytes2InputStream(byte[] bytes) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
255
        return new ByteArrayInputStream(bytes);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
256
    }
257

                  
262
     * @return 字节数组
263
     */
264
    public static byte[] outputStream2Bytes(OutputStream out) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
265
        if (out == null) return null;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Return an empty array instead of null.     NEW     squid:S1168  
Empty arrays and collections should be returned instead of null
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
266
        return ((ByteArrayOutputStream) out).toByteArray();
267
    }
273
     * @return 字节数组
274
     */
275
    public static OutputStream bytes2OutputStream(byte[] bytes) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
276
        ByteArrayOutputStream os = null;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
277
        try {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Change this "try" to a try-with-resources. (sonar.java.source not set. Assuming 7 or greater.)     NEW     squid:S2093  
Try-with-resources should be used
278
            os = new ByteArrayOutputStream();
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
279
            os.write(bytes);
280
            return os;
281
        } catch (IOException e) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "catch" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
Either log or rethrow this exception.     NEW     squid:S1166  
Exception handlers should preserve the original exceptions
282
            e.printStackTrace();
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Use a logger to log this exception.     NEW     squid:S1148  
Throwable.printStackTrace(...) should not be called
283
            return null;
284
        } finally {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "finally" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
285
            FileUtils.closeIO(os);
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
286
        }
287
    }
294
     * @return 字符串
295
     */
296
    public static String inputStream2String(InputStream is, String charsetName) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
297
        if (is == null || StringUtils.isSpace(charsetName)) return null;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
298
        try {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
299
            return new String(inputStream2Bytes(is), charsetName);
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
300
        } catch (UnsupportedEncodingException e) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "catch" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
Either log or rethrow this exception.     NEW     squid:S1166  
Exception handlers should preserve the original exceptions
301
            e.printStackTrace();
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Use a logger to log this exception.     NEW     squid:S1148  
Throwable.printStackTrace(...) should not be called
302
            return null;
303
        }
311
     * @return 输入流
312
     */
313
    public static InputStream string2InputStream(String string, String charsetName) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
314
        if (string == null || StringUtils.isSpace(charsetName)) return null;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
315
        try {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
316
            return new ByteArrayInputStream(string.getBytes(charsetName));
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
317
        } catch (UnsupportedEncodingException e) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "catch" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
Either log or rethrow this exception.     NEW     squid:S1166  
Exception handlers should preserve the original exceptions
318
            e.printStackTrace();
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Use a logger to log this exception.     NEW     squid:S1148  
Throwable.printStackTrace(...) should not be called
319
            return null;
320
        }
328
     * @return 字符串
329
     */
330
    public static String outputStream2String(OutputStream out, String charsetName) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
331
        if (out == null) return null;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
332
        try {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
333
            return new String(outputStream2Bytes(out), charsetName);
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
334
        } catch (UnsupportedEncodingException e) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "catch" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
Either log or rethrow this exception.     NEW     squid:S1166  
Exception handlers should preserve the original exceptions
335
            e.printStackTrace();
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Use a logger to log this exception.     NEW     squid:S1148  
Throwable.printStackTrace(...) should not be called
336
            return null;
337
        }
345
     * @return 输入流
346
     */
347
    public static OutputStream string2OutputStream(String string, String charsetName) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
348
        if (string == null || StringUtils.isSpace(charsetName)) return null;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
349
        try {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
350
            return bytes2OutputStream(string.getBytes(charsetName));
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
351
        } catch (UnsupportedEncodingException e) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "catch" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
Either log or rethrow this exception.     NEW     squid:S1166  
Exception handlers should preserve the original exceptions
352
            e.printStackTrace();
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Use a logger to log this exception.     NEW     squid:S1148  
Throwable.printStackTrace(...) should not be called
353
            return null;
354
        }
362
     * @return 字节数组
363
     */
364
    public static byte[] bitmap2Bytes(Bitmap bitmap, Bitmap.CompressFormat format) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
365
        if (bitmap == null) return null;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Return an empty array instead of null.     NEW     squid:S1168  
Empty arrays and collections should be returned instead of null
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
366
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
367
        bitmap.compress(format, 100, baos);
Assign this magic number 100 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
368
        return baos.toByteArray();
369
    }
375
     * @return bitmap
376
     */
377
    public static Bitmap bytes2Bitmap(byte[] bytes) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
378
        return (bytes == null || bytes.length == 0) ? null : BitmapFactory.decodeByteArray(bytes, 0, bytes.length);
Convert this usage of the ternary operator to an "if"/"else" structure.     NEW     squid:S1774  
The ternary operator should not be used
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
379
    }
380

                  
385
     * @return bitmap
386
     */
387
    public static Bitmap drawable2Bitmap(Drawable drawable) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
388
        return drawable == null ? null : ((BitmapDrawable) drawable).getBitmap();
Convert this usage of the ternary operator to an "if"/"else" structure.     NEW     squid:S1774  
The ternary operator should not be used
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
389
    }
390

                  
396
     * @return drawable
397
     */
398
    public static Drawable bitmap2Drawable(Resources res, Bitmap bitmap) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
399
        return bitmap == null ? null : new BitmapDrawable(res, bitmap);
Convert this usage of the ternary operator to an "if"/"else" structure.     NEW     squid:S1774  
The ternary operator should not be used
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
400
    }
401

                  
407
     * @return 字节数组
408
     */
409
    public static byte[] drawable2Bytes(Drawable drawable, Bitmap.CompressFormat format) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
410
        return bitmap2Bytes(drawable2Bitmap(drawable), format);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
411
    }
412

                  
418
     * @return drawable
419
     */
420
    public static Drawable bytes2Drawable(Resources res, byte[] bytes) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
421
        return bitmap2Drawable(res, bytes2Bitmap(bytes));
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
422
    }
423

                  
428
     * @return bitmap
429
     */
430
    public static Bitmap view2Bitmap(View view) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
431
        if (view == null) return null;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
432
        Bitmap ret = Bitmap.createBitmap(view.getWidth(), view.getHeight(), Bitmap.Config.ARGB_8888);
433
        Canvas canvas = new Canvas(ret);
434
        Drawable bgDrawable = view.getBackground();
435
        if (bgDrawable != null) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
436
            bgDrawable.draw(canvas);
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
437
        }else {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "else" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
438
            canvas.drawColor(Color.WHITE);
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
439
        }
440
        view.draw(canvas);
449
     * @return px值
450
     */
451
    public static int dp2px(Context context, float dpValue) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
452
        final float scale = context.getResources().getDisplayMetrics().density;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
453
        return (int) (dpValue * scale + 0.5f);
Use a "double" or "BigDecimal" instead.     NEW     squid:S2164  
Math should not be performed on floats
Upper-case this literal "f" suffix.     NEW     squid:S818  
Literal suffixes should be upper case
Assign this magic number 0.5f to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
454
    }
455

                  
461
     * @return dp值
462
     */
463
    public static int px2dp(Context context, float pxValue) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
464
        final float scale = context.getResources().getDisplayMetrics().density;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
465
        return (int) (pxValue / scale + 0.5f);
Use a "double" or "BigDecimal" instead.     NEW     squid:S2164  
Math should not be performed on floats
Upper-case this literal "f" suffix.     NEW     squid:S818  
Literal suffixes should be upper case
Assign this magic number 0.5f to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
466
    }
467

                  
473
     * @return px值
474
     */
475
    public static int sp2px(Context context, float spValue) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
476
        final float fontScale = context.getResources().getDisplayMetrics().scaledDensity;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
477
        return (int) (spValue * fontScale + 0.5f);
Use a "double" or "BigDecimal" instead.     NEW     squid:S2164  
Math should not be performed on floats
Upper-case this literal "f" suffix.     NEW     squid:S818  
Literal suffixes should be upper case
Assign this magic number 0.5f to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
478
    }
479

                  
485
     * @return sp值
486
     */
487
    public static int px2sp(Context context, float pxValue) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
488
        final float fontScale = context.getResources().getDisplayMetrics().scaledDensity;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
489
        return (int) (pxValue / fontScale + 0.5f);
Use a "double" or "BigDecimal" instead.     NEW     squid:S2164  
Math should not be performed on floats
Upper-case this literal "f" suffix.     NEW     squid:S818  
Literal suffixes should be upper case
Assign this magic number 0.5f to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
490
    }
491
}
53
New issues
Add or update the header of this file.     NEW     squid:S1451
Copyright and license headers should be defined
Replace all tab characters in this file by sequences of white-spaces.     NEW     squid:S00105
Tabulation characters should not be used
1
package com.blankj.utilcode.utils;
2

                  
3
import android.annotation.SuppressLint;
Remove this unused import 'android.annotation.SuppressLint'.     NEW     squid:UselessImportCheck  
Useless imports should be removed
4
import android.content.Context;
5
import android.content.pm.PackageInfo;
7
import android.os.Build;
8
import android.os.Environment;
9
import android.util.Log;
Remove this unused import 'android.util.Log'.     NEW     squid:UselessImportCheck  
Useless imports should be removed
10

                  
11
import java.io.File;
12
import java.io.FileWriter;
Remove this unused import 'java.io.FileWriter'.     NEW     squid:UselessImportCheck  
Useless imports should be removed
13
import java.io.IOException;
Remove this unused import 'java.io.IOException'.     NEW     squid:UselessImportCheck  
Useless imports should be removed
14
import java.io.PrintWriter;
15
import java.io.StringWriter;
16
import java.io.Writer;
17
import java.lang.Thread.UncaughtExceptionHandler;
18
import java.nio.channels.NonWritableChannelException;
Remove this unused import 'java.nio.channels.NonWritableChannelException'.     NEW     squid:UselessImportCheck  
Useless imports should be removed
19

                  
20
import static android.content.ContentValues.TAG;
28
 * </pre>
29
 */
30
public class CrashUtils implements Thread.UncaughtExceptionHandler {
Make this class "final" or add a public constructor.     NEW     squid:S2974  
Classes without "public" constructors should be "final"
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
31

                  
32
    private volatile static CrashUtils mInstance;
Reorder the modifiers to comply with the Java Language Specification.     NEW     squid:ModifiersOrderCheck  
Modifiers should be declared in the correct order
Make this line start at column 3.     NEW     squid:IndentationCheck  
Source code should be indented consistently
33
    private Context mContext;
34
    private UncaughtExceptionHandler mHandler;
35
    private boolean mInitialized;
36

                  
37
    private CrashUtils(){
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
38

                  
39
    }
44
     * @return 单例
45
     */
46
    public static CrashUtils getInstance() {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
47
        synchronized (CrashUtils.class) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
48
            if (null == mInstance) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
49
                mInstance = new CrashUtils();
Make this line start at column 9.     NEW     squid:IndentationCheck  
Source code should be indented consistently
50
            }
51
        }
58
     * @param context 上下文
59
     */
60
    public void init(Context context) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
61
        if (mInitialized) return;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
62
        mInitialized = true;
63
	
64

                  
65
	String myTimeString = "test error2";
Remove this unused "myTimeString" local variable.     NEW     squid:S1481  
Unused local variables should be removed
Remove this useless assignment to local variable "myTimeString".     NEW     squid:S1854  
Dead stores should be removed
66

                  
67

                  
72

                  
73
    @Override
74
    public void uncaughtException(Thread thread, Throwable throwable) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
75
        String dir;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
76
        if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
77
            dir = mContext.getExternalCacheDir().getPath();
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
78
        } else {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "else" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
79
            dir = mContext.getCacheDir().getPath();
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
80
        }
81
        String fullPath = dir + File.separator + "crash_" + TimeUtils.getCurTimeString() + ".txt";
82
        if (!FileUtils.createOrExistsFile(fullPath)) return;
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
83
        StringBuilder sb = new StringBuilder();
84
        sb.append(getCrashHead());
85
        Writer writer = new StringWriter();
86
        PrintWriter pw = null;
87
        try {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Change this "try" to a try-with-resources. (sonar.java.source not set. Assuming 7 or greater.)     NEW     squid:S2093  
Try-with-resources should be used
88
            pw = new PrintWriter(writer);
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
89
            throwable.printStackTrace(pw);
90
            Throwable cause = throwable.getCause();
91
            while (cause != null) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
92
                cause.printStackTrace(pw);
Make this line start at column 9.     NEW     squid:IndentationCheck  
Source code should be indented consistently
93
                cause = cause.getCause();
94
            }
95
        } finally {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "finally" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
96
            FileUtils.closeIO(pw);
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
97
        }
98
        sb.append(writer.toString());
99
        FileUtils.writeFileFromString(fullPath, sb.toString(), false);
100
        if (mHandler != null) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
101
            mHandler.uncaughtException(thread, throwable);
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
102
        }
103
    }
108
     * @return 崩溃头
109
     */
110
    public StringBuilder getCrashHead() {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
111
        StringBuilder sb = new StringBuilder();
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
112
	String myTimeString = "test error3";
Remove this unused "myTimeString" local variable.     NEW     squid:S1481  
Unused local variables should be removed
Remove this useless assignment to local variable "myTimeString".     NEW     squid:S1854  
Dead stores should be removed
113

                  
114
        try {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
115
            PackageInfo pi = mContext.getPackageManager().getPackageInfo(mContext.getPackageName(), 0);
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
116
            sb.append("\n************* Crash Log Head ****************");
117
            sb.append("\nDevice Manufacturer: ").append(Build.MANUFACTURER);// 设备厂商
122
            sb.append("\nApp VersionCode    : ").append(pi.versionCode);
123
            sb.append("\n************* Crash Log Head ****************\n\n");
124
        } catch (PackageManager.NameNotFoundException e) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "catch" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
Either log or rethrow this exception.     NEW     squid:S1166  
Exception handlers should preserve the original exceptions
125
            e.printStackTrace();
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
126
        }
127
        return sb;
43
New issues
Add or update the header of this file.     NEW     squid:S1451
Copyright and license headers should be defined
Add a new line at the end of this file.     NEW     squid:S00113
Files should contain an empty new line at the end
1
package com.blankj.utilcode.utils;
2

                  
6
import android.os.Build;
7
import android.provider.Settings;
8
import android.telephony.TelephonyManager;
Remove this unused import 'android.telephony.TelephonyManager'.     NEW     squid:UselessImportCheck  
Useless imports should be removed
9

                  
10
import java.io.IOException;
20
 * </pre>
21
 */
22
public class DeviceUtils {
Make this class "final" or add a public constructor.     NEW     squid:S2974  
Classes without "public" constructors should be "final"
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
23

                  
24
    private DeviceUtils() {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Make this line start at column 3.     NEW     squid:IndentationCheck  
Source code should be indented consistently
25
        throw new UnsupportedOperationException("u can't instantiate me...");
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
26
    }
27

                  
29
     * 获取系统版本号
30
     */
31
    public static int getSDK() {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
32
        return android.os.Build.VERSION.SDK_INT;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Replace this fully qualified name with "android.os.Build"     NEW     squid:S1942  
Simple class names should be used
33
    }
34

                  
40
     * @return AndroidID
41
     */
42
    public static String getAndroidID(Context context) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
43
        return Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
44
    }
45

                  
51
     * @return MAC地址
52
     */
53
    public static String getMacAddress(Context context) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
54
        WifiManager wifi = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
55
        WifiInfo info = wifi.getConnectionInfo();
56
        if (info != null) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
57
            String macAddress = info.getMacAddress();
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
58
            if (macAddress != null) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
59
                return macAddress.replace(":", "");
Make this line start at column 9.     NEW     squid:IndentationCheck  
Source code should be indented consistently
60
            }
61
        }
70
     */
71

                  
72
    public static String getMacAddress() {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
73
        String macAddress = null;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
74
        LineNumberReader lnr = null;
75
        InputStreamReader isr = null;
76
        try {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Change this "try" to a try-with-resources. (sonar.java.source not set. Assuming 7 or greater.)     NEW     squid:S2093  
Try-with-resources should be used
77
            Process pp = Runtime.getRuntime().exec("cat /sys/class/net/wlan0/address");
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
78
            isr = new InputStreamReader(pp.getInputStream());
Remove this use of constructor "InputStreamReader(InputStream)"     NEW     squid:S1943  
Classes and methods that rely on the default system encoding should not be used
79
            lnr = new LineNumberReader(isr);
80
            macAddress = lnr.readLine().replace(":", "");
81
        } catch (IOException e) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "catch" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
Either log or rethrow this exception.     NEW     squid:S1166  
Exception handlers should preserve the original exceptions
82
            e.printStackTrace();
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Use a logger to log this exception.     NEW     squid:S1148  
Throwable.printStackTrace(...) should not be called
83
        } finally {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "finally" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
84
            FileUtils.closeIO(lnr, isr);
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
85
        }
86
        return macAddress == null ? "" : macAddress;
Convert this usage of the ternary operator to an "if"/"else" structure.     NEW     squid:S1774  
The ternary operator should not be used
87
    }
88

                  
92
     * @return 设备厂商
93
     */
94
    public static String getManufacturer() {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
95
        return Build.MANUFACTURER;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
96
    }
97

                  
101
     * @return 设备型号
102
     */
103
    public static String getModel() {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
104
        String model = Build.MODEL;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
105
        if (model != null) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
106
            model = model.trim().replaceAll("\\s*", "");
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
107
        } else {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "else" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
108
            model = "";
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
109
        }
110
        return model;
86
New issues
Add or update the header of this file.     NEW     squid:S1451
Copyright and license headers should be defined
1
package com.blankj.utilcode.utils;
2

                  
19
 * </pre>
20
 */
21
public class EmptyUtils {
Make this class "final" or add a public constructor.     NEW     squid:S2974  
Classes without "public" constructors should be "final"
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
22

                  
23
    private EmptyUtils() {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Make this line start at column 3.     NEW     squid:IndentationCheck  
Source code should be indented consistently
24
        throw new UnsupportedOperationException("u can't instantiate me...");
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
25
    }
26

                  
31
     * @return {@code true}: 为空<br>{@code false}: 不为空
32
     */
33
    public static boolean isEmpty(Object obj) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Reduce the number of returns of this method 10, down to the maximum allowed 3.     NEW     squid:S1142  
Methods should not have too many return statements
The Cyclomatic Complexity of this method "isEmpty" is 28 which is greater than 10 authorized.     NEW     squid:MethodCyclomaticComplexity  
Methods should not be too complex
34
        if (obj == null) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
35
            return true;
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
36
        } else if (obj instanceof String && obj.toString().length() == 0) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "else" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
This branch's code block is the same as the block for the branch on line 34.     NEW     squid:S1871  
Two branches in the same conditional structure should not have exactly the same implementation
37
            return true;
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
38
        } else if (obj.getClass().isArray() && Array.getLength(obj) == 0) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "else" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
This branch's code block is the same as the block for the branch on line 36.     NEW     squid:S1871  
Two branches in the same conditional structure should not have exactly the same implementation
39
            return true;
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
40
        } else if (obj instanceof Collection && ((Collection) obj).isEmpty()) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "else" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
This branch's code block is the same as the block for the branch on line 38.     NEW     squid:S1871  
Two branches in the same conditional structure should not have exactly the same implementation
41
            return true;
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
42
        } else if (obj instanceof Map && ((Map) obj).isEmpty()) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "else" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
This branch's code block is the same as the block for the branch on line 40.     NEW     squid:S1871  
Two branches in the same conditional structure should not have exactly the same implementation
43
            return true;
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
44
        } else if (obj instanceof SparseArray && ((SparseArray) obj).size() == 0) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "else" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
This branch's code block is the same as the block for the branch on line 42.     NEW     squid:S1871  
Two branches in the same conditional structure should not have exactly the same implementation
45
            return true;
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
46
        } else if (obj instanceof SparseBooleanArray && ((SparseBooleanArray) obj).size() == 0) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "else" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
This branch's code block is the same as the block for the branch on line 44.     NEW     squid:S1871  
Two branches in the same conditional structure should not have exactly the same implementation
47
            return true;
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
48
        } else if (obj instanceof SparseIntArray && ((SparseIntArray) obj).size() == 0) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "else" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
This branch's code block is the same as the block for the branch on line 46.     NEW     squid:S1871  
Two branches in the same conditional structure should not have exactly the same implementation
49
            return true;
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
50
        } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "else" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
51
            if (obj instanceof SparseLongArray && ((SparseLongArray) obj).size() == 0) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Merge this if statement with the enclosing one.     NEW     squid:S1066  
Collapsible "if" statements should be merged
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
52
                return true;
Make this line start at column 9.     NEW     squid:IndentationCheck  
Source code should be indented consistently
53
            }
54
        }
63
     * @return {@code true}: 非空<br>{@code false}: 空
64
     */
65
    public static boolean isNotEmpty(Object obj) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Reduce the number of returns of this method 10, down to the maximum allowed 3.     NEW     squid:S1142  
Methods should not have too many return statements
The Cyclomatic Complexity of this method "isNotEmpty" is 28 which is greater than 10 authorized.     NEW     squid:MethodCyclomaticComplexity  
Methods should not be too complex
66
        if (obj == null) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
67
            return false;
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
68
        } else if (obj instanceof String && obj.toString().length() == 0) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "else" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
This branch's code block is the same as the block for the branch on line 66.     NEW     squid:S1871  
Two branches in the same conditional structure should not have exactly the same implementation
69
            return false;
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
70
        } else if (obj.getClass().isArray() && Array.getLength(obj) == 0) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "else" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
This branch's code block is the same as the block for the branch on line 68.     NEW     squid:S1871  
Two branches in the same conditional structure should not have exactly the same implementation
71
            return false;
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
72
        } else if (obj instanceof Collection && ((Collection) obj).isEmpty()) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "else" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
This branch's code block is the same as the block for the branch on line 70.     NEW     squid:S1871  
Two branches in the same conditional structure should not have exactly the same implementation
73
            return false;
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
74
        } else if (obj instanceof Map && ((Map) obj).isEmpty()) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "else" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
This branch's code block is the same as the block for the branch on line 72.     NEW     squid:S1871  
Two branches in the same conditional structure should not have exactly the same implementation
75
            return false;
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
76
        } else if (obj instanceof SparseArray && ((SparseArray) obj).size() == 0) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "else" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
This branch's code block is the same as the block for the branch on line 74.     NEW     squid:S1871  
Two branches in the same conditional structure should not have exactly the same implementation
77
            return false;
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
78
        } else if (obj instanceof SparseBooleanArray && ((SparseBooleanArray) obj).size() == 0) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "else" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
This branch's code block is the same as the block for the branch on line 76.     NEW     squid:S1871  
Two branches in the same conditional structure should not have exactly the same implementation
79
            return false;
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
80
        } else if (obj instanceof SparseIntArray && ((SparseIntArray) obj).size() == 0) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "else" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
This branch's code block is the same as the block for the branch on line 78.     NEW     squid:S1871  
Two branches in the same conditional structure should not have exactly the same implementation
81
            return false;
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
82
        } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "else" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
83
            if (obj instanceof SparseLongArray && ((SparseLongArray) obj).size() == 0) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Merge this if statement with the enclosing one.     NEW     squid:S1066  
Collapsible "if" statements should be merged
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
84
                return false;
Make this line start at column 9.     NEW     squid:IndentationCheck  
Source code should be indented consistently
85
            }
86
        }
84
New issues
Add or update the header of this file.     NEW     squid:S1451
Copyright and license headers should be defined
1
package com.blankj.utilcode.utils;
2

                  
17
 * </pre>
18
 */
19
public class EncodeUtils {
Make this class "final" or add a public constructor.     NEW     squid:S2974  
Classes without "public" constructors should be "final"
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
20

                  
21
    private EncodeUtils() {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Make this line start at column 3.     NEW     squid:IndentationCheck  
Source code should be indented consistently
22
        throw new UnsupportedOperationException("u can't instantiate me...");
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
23
    }
24

                  
30
     * @return 编码为UTF-8的字符串
31
     */
32
    public static String urlEncode(String input) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
33
        return urlEncode(input, "UTF-8");
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
34
    }
35

                  
42
     * @return 编码为字符集的字符串
43
     */
44
    public static String urlEncode(String input, String charset) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
45
        try {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
46
            return URLEncoder.encode(input, charset);
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
47
        } catch (UnsupportedEncodingException e) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "catch" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
Either log or rethrow this exception.     NEW     squid:S1166  
Exception handlers should preserve the original exceptions
48
            return input;
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
49
        }
50
    }
57
     * @return URL解码后的字符串
58
     */
59
    public static String urlDecode(String input) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
60
        return urlDecode(input, "UTF-8");
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
61
    }
62

                  
69
     * @return URL解码为指定字符集的字符串
70
     */
71
    public static String urlDecode(String input, String charset) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
72
        try {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
73
            return URLDecoder.decode(input, charset);
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
74
        } catch (UnsupportedEncodingException e) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "catch" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
Either log or rethrow this exception.     NEW     squid:S1166  
Exception handlers should preserve the original exceptions
75
            return input;
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
76
        }
77
    }
83
     * @return Base64编码后的字符串
84
     */
85
    public static byte[] base64Encode(String input) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
86
        return base64Encode(input.getBytes());
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Remove this use of "getBytes"     NEW     squid:S1943  
Classes and methods that rely on the default system encoding should not be used
87
    }
88

                  
93
     * @return Base64编码后的字符串
94
     */
95
    public static byte[] base64Encode(byte[] input) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
96
        return Base64.encode(input, Base64.NO_WRAP);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
97
    }
98

                  
103
     * @return Base64编码后的字符串
104
     */
105
    public static String base64Encode2String(byte[] input) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
106
        return Base64.encodeToString(input, Base64.NO_WRAP);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
107
    }
108

                  
113
     * @return Base64解码后的字符串
114
     */
115
    public static byte[] base64Decode(String input) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
116
        return Base64.decode(input, Base64.NO_WRAP);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
117
    }
118

                  
123
     * @return Base64解码后的字符串
124
     */
125
    public static byte[] base64Decode(byte[] input) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
126
        return Base64.decode(input, Base64.NO_WRAP);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
127
    }
128

                  
134
     * @return Base64URL安全编码后的字符串
135
     */
136
    public static byte[] base64UrlSafeEncode(String input) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
137
        return Base64.encode(input.getBytes(), Base64.URL_SAFE);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Remove this use of "getBytes"     NEW     squid:S1943  
Classes and methods that rely on the default system encoding should not be used
138
    }
139

                  
144
     * @return Html编码后的字符串
145
     */
146
    public static String htmlEncode(String input) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
The Cyclomatic Complexity of this method "htmlEncode" is 19 which is greater than 10 authorized.     NEW     squid:MethodCyclomaticComplexity  
Methods should not be too complex
147
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
148
            return Html.escapeHtml(input);
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
149
        } else {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "else" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
150
            // 参照Html.escapeHtml()中代码
151
            StringBuilder out = new StringBuilder();
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
152
            for (int i = 0, len = input.length(); i < len; i++) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
153
                char c = input.charAt(i);
Make this line start at column 9.     NEW     squid:IndentationCheck  
Source code should be indented consistently
154
                if (c == '<') {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
155
                    out.append("&lt;");
Make this line start at column 11.     NEW     squid:IndentationCheck  
Source code should be indented consistently
156
                } else if (c == '>') {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "else" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
157
                    out.append("&gt;");
Make this line start at column 11.     NEW     squid:IndentationCheck  
Source code should be indented consistently
158
                } else if (c == '&') {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "else" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
159
                    out.append("&amp;");
Make this line start at column 11.     NEW     squid:IndentationCheck  
Source code should be indented consistently
160
                } else if (c >= 0xD800 && c <= 0xDFFF) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "else" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
161
                    if (c < 0xDC00 && i + 1 < len) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Make this line start at column 11.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Refactor this code to not nest more than 3 if/for/while/switch/try statements.     NEW     squid:S134  
Control flow statements "if", "for", "while", "switch" and "try" should not be nested too deeply
162
                        char d = input.charAt(i + 1);
Make this line start at column 13.     NEW     squid:IndentationCheck  
Source code should be indented consistently
163
                        if (d >= 0xDC00 && d <= 0xDFFF) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
164
                            i++;
Refactor the code in order to not assign to this loop counter from within the loop body.     NEW     squid:ForLoopCounterChangedCheck  
"for" loop stop conditions should be invariant
Make this line start at column 15.     NEW     squid:IndentationCheck  
Source code should be indented consistently
165
                            int codepoint = 0x010000 | (int) c - 0xD800 << 10 | (int) d - 0xDC00;
Add parentheses to make the operator precedence explicit.     NEW     squid:S864  
Limited dependence should be placed on operator precedence rules in expressions
Assign this magic number 10 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
166
                            out.append("&#").append(codepoint).append(";");
167
                        }
168
                    }
169
                } else if (c > 0x7E || c < ' ') {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "else" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
170
                    out.append("&#").append((int) c).append(";");
Make this line start at column 11.     NEW     squid:IndentationCheck  
Source code should be indented consistently
171
                } else if (c == ' ') {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "else" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
172
                    while (i + 1 < len && input.charAt(i + 1) == ' ') {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Make this line start at column 11.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Refactor this code to not nest more than 3 if/for/while/switch/try statements.     NEW     squid:S134  
Control flow statements "if", "for", "while", "switch" and "try" should not be nested too deeply
173
                        out.append("&nbsp;");
Make this line start at column 13.     NEW     squid:IndentationCheck  
Source code should be indented consistently
174
                        i++;
Refactor the code in order to not assign to this loop counter from within the loop body.     NEW     squid:ForLoopCounterChangedCheck  
"for" loop stop conditions should be invariant
175
                    }
176
                    out.append(' ');
177
                } else {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "else" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
178
                    out.append(c);
Make this line start at column 11.     NEW     squid:IndentationCheck  
Source code should be indented consistently
179
                }
180
            }
189
     * @return Html解码后的字符串
190
     */
191
    public static String htmlDecode(String input) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
192
        return Html.fromHtml(input).toString();
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
193
    }
194
}
165
New issues
Add or update the header of this file.     NEW     squid:S1451
Copyright and license headers should be defined
Add a new line at the end of this file.     NEW     squid:S00113
Files should contain an empty new line at the end
1
package com.blankj.utilcode.utils;
2

                  
23
 * </pre>
24
 */
25
public class EncryptUtils {
Make this class "final" or add a public constructor.     NEW     squid:S2974  
Classes without "public" constructors should be "final"
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
class "EncryptUtils" has 48 methods, which is greater than the 35 authorized. Split it into smaller classes.     NEW     squid:S1448  
Classes should not have too many methods
26

                  
27
    private EncryptUtils() {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Make this line start at column 3.     NEW     squid:IndentationCheck  
Source code should be indented consistently
28
        throw new UnsupportedOperationException("u can't instantiate me...");
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
29
    }
30

                  
36
     * @return 16进制密文
37
     */
38
    public static String encryptMD2ToString(String data) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document the parameter(s): data     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
Document this method return value.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
39
        return encryptMD2ToString(data.getBytes());
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Remove this use of "getBytes"     NEW     squid:S1943  
Classes and methods that rely on the default system encoding should not be used
40
    }
41

                  
46
     * @return 16进制密文
47
     */
48
    public static String encryptMD2ToString(byte[] data) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
49
        return bytes2HexString(encryptMD2(data));
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
50
    }
51

                  
56
     * @return 密文字节数组
57
     */
58
    public static byte[] encryptMD2(byte[] data) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
59
        return encryptAlgorithm(data, "MD2");
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
60
    }
61

                  
66
     * @return 16进制密文
67
     */
68
    public static String encryptMD5ToString(String data) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
69
        return encryptMD5ToString(data.getBytes());
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Remove this use of "getBytes"     NEW     squid:S1943  
Classes and methods that rely on the default system encoding should not be used
70
    }
71

                  
77
     * @return 16进制加盐密文
78
     */
79
    public static String encryptMD5ToString(String data, String salt) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
80
        return bytes2HexString(encryptMD5((data + salt).getBytes()));
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Remove this use of "getBytes"     NEW     squid:S1943  
Classes and methods that rely on the default system encoding should not be used
81
    }
82

                  
87
     * @return 16进制密文
88
     */
89
    public static String encryptMD5ToString(byte[] data) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
90
        return bytes2HexString(encryptMD5(data));
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
91
    }
92

                  
98
     * @return 16进制加盐密文
99
     */
100
    public static String encryptMD5ToString(byte[] data, byte[] salt) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
101
        byte[] dataSalt = new byte[data.length + salt.length];
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
102
        System.arraycopy(data, 0, dataSalt, 0, data.length);
103
        System.arraycopy(salt, 0, dataSalt, data.length, salt.length);
111
     * @return 密文字节数组
112
     */
113
    public static byte[] encryptMD5(byte[] data) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
114
        return encryptAlgorithm(data, "MD5");
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
115
    }
116

                  
121
     * @return 文件的16进制密文
122
     */
123
    public static String encryptMD5File2String(String filePath) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
124
        return encryptMD5File2String(new File(filePath));
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
125
    }
126

                  
131
     * @return 文件的MD5校验码
132
     */
133
    public static byte[] encryptMD5File(String filePath) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
134
        return encryptMD5File(new File(filePath));
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
135
    }
136

                  
141
     * @return 文件的16进制密文
142
     */
143
    public static String encryptMD5File2String(File file) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
144
        return encryptMD5File(file) != null ? bytes2HexString(encryptMD5File(file)) : "";
Convert this usage of the ternary operator to an "if"/"else" structure.     NEW     squid:S1774  
The ternary operator should not be used
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
145
    }
146

                  
151
     * @return 文件的MD5校验码
152
     */
153
    public static byte[] encryptMD5File(File file) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
154
        FileInputStream fis = null;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
155
        try {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Change this "try" to a try-with-resources. (sonar.java.source not set. Assuming 7 or greater.)     NEW     squid:S2093  
Try-with-resources should be used
156
            fis = new FileInputStream(file);
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
157
            FileChannel channel = fis.getChannel();
158
            MappedByteBuffer buffer = channel.map(FileChannel.MapMode.READ_ONLY, 0, file.length());
159
            MessageDigest md = MessageDigest.getInstance("MD5");
Use a stronger hashing algorithm than MD5.     NEW     squid:S2070  
SHA-1 and Message-Digest hash algorithms should not be used
160
            md.update(buffer);
161
            return md.digest();
162
        } catch (NoSuchAlgorithmException | IOException e) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "catch" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
Either log or rethrow this exception.     NEW     squid:S1166  
Exception handlers should preserve the original exceptions
163
            e.printStackTrace();
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Use a logger to log this exception.     NEW     squid:S1148  
Throwable.printStackTrace(...) should not be called
164
        } finally {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "finally" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
165
            FileUtils.closeIO(fis);
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
166
        }
167
        return null;
Return an empty array instead of null.     NEW     squid:S1168  
Empty arrays and collections should be returned instead of null
168
    }
169

                  
174
     * @return 16进制密文
175
     */
176
    public static String encryptSHA1ToString(String data) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
177
        return encryptSHA1ToString(data.getBytes());
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Remove this use of "getBytes"     NEW     squid:S1943  
Classes and methods that rely on the default system encoding should not be used
178
    }
179

                  
184
     * @return 16进制密文
185
     */
186
    public static String encryptSHA1ToString(byte[] data) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
187
        return bytes2HexString(encryptSHA1(data));
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
188
    }
189

                  
194
     * @return 密文字节数组
195
     */
196
    public static byte[] encryptSHA1(byte[] data) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
197
        return encryptAlgorithm(data, "SHA-1");
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
198
    }
199

                  
204
     * @return 16进制密文
205
     */
206
    public static String encryptSHA224ToString(String data) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
207
        return encryptSHA224ToString(data.getBytes());
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Remove this use of "getBytes"     NEW     squid:S1943  
Classes and methods that rely on the default system encoding should not be used
208
    }
209

                  
214
     * @return 16进制密文
215
     */
216
    public static String encryptSHA224ToString(byte[] data) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
217
        return bytes2HexString(encryptSHA224(data));
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
218
    }
219

                  
224
     * @return 密文字节数组
225
     */
226
    public static byte[] encryptSHA224(byte[] data) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
227
        return encryptAlgorithm(data, "SHA-224");
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
228
    }
229

                  
234
     * @return 16进制密文
235
     */
236
    public static String encryptSHA256ToString(String data) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
237
        return encryptSHA256ToString(data.getBytes());
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Remove this use of "getBytes"     NEW     squid:S1943  
Classes and methods that rely on the default system encoding should not be used
238
    }
239

                  
244
     * @return 16进制密文
245
     */
246
    public static String encryptSHA256ToString(byte[] data) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
247
        return bytes2HexString(encryptSHA256(data));
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
248
    }
249

                  
254
     * @return 密文字节数组
255
     */
256
    public static byte[] encryptSHA256(byte[] data) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
257
        return encryptAlgorithm(data, "SHA-256");
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
258
    }
259

                  
264
     * @return 16进制密文
265
     */
266
    public static String encryptSHA384ToString(String data) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
267
        return encryptSHA384ToString(data.getBytes());
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Remove this use of "getBytes"     NEW     squid:S1943  
Classes and methods that rely on the default system encoding should not be used
268
    }
269

                  
274
     * @return 16进制密文
275
     */
276
    public static String encryptSHA384ToString(byte[] data) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
277
        return bytes2HexString(encryptSHA384(data));
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
278
    }
279

                  
284
     * @return 密文字节数组
285
     */
286
    public static byte[] encryptSHA384(byte[] data) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
287
        return encryptAlgorithm(data, "SHA-384");
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
288
    }
289

                  
294
     * @return 16进制密文
295
     */
296
    public static String encryptSHA512ToString(String data) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
297
        return encryptSHA512ToString(data.getBytes());
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Remove this use of "getBytes"     NEW     squid:S1943  
Classes and methods that rely on the default system encoding should not be used
298
    }
299

                  
304
     * @return 16进制密文
305
     */
306
    public static String encryptSHA512ToString(byte[] data) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
307
        return bytes2HexString(encryptSHA512(data));
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
308
    }
309

                  
314
     * @return 密文字节数组
315
     */
316
    public static byte[] encryptSHA512(byte[] data) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
317
        return encryptAlgorithm(data, "SHA-512");
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
318
    }
319

                  
325
     * @return 密文字节数组
326
     */
327
    private static byte[] encryptAlgorithm(byte[] data, String algorithm) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
328
        try {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
329
            MessageDigest md = MessageDigest.getInstance(algorithm);
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
330
            md.update(data);
331
            return md.digest();
332
        } catch (NoSuchAlgorithmException e) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "catch" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
Either log or rethrow this exception.     NEW     squid:S1166  
Exception handlers should preserve the original exceptions
333
            e.printStackTrace();
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Use a logger to log this exception.     NEW     squid:S1148  
Throwable.printStackTrace(...) should not be called
334
        }
335
        return new byte[0];
343
     * <p>填充方式有:NoPadding、ZerosPadding、PKCS5Padding</p>
344
     */
345
    public static String DES_Transformation = "DES/ECB/NoPadding";
Rename this field "DES_Transformation" to match the regular expression '^[a-z][a-zA-Z0-9]*$'.     NEW     squid:S3008  
Static non-final field names should comply with a naming convention
Make this "public static DES_Transformation" field final     NEW     squid:S1444  
"public static" fields should be constant
Move this variable to comply with Java Code Conventions.     NEW     squid:S1213  
The members of an interface declaration or class should appear in a pre-defined order
Make DES_Transformation a static final constant or non-public and provide accessors if needed.     NEW     squid:ClassVariableVisibilityCheck  
Class variable fields should not have public accessibility
346
    private static final String DES_Algorithm = "DES";
Move this variable to comply with Java Code Conventions.     NEW     squid:S1213  
The members of an interface declaration or class should appear in a pre-defined order
Rename this constant name to match the regular expression '^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$'.     NEW     squid:S00115  
Constant names should comply with a naming convention
347

                  
348
    /**
354
     * @return 密文或者明文,适用于DES,3DES,AES
355
     */
356
    public static byte[] DESTemplet(byte[] data, byte[] key, String algorithm, String transformation, boolean isEncrypt) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Provide multiple methods instead of using "isEncrypt" to determine which action to take.     NEW     squid:S2301  
Public methods should not contain selector arguments
Rename this method name to match the regular expression '^[a-z][a-zA-Z0-9]*$'.     NEW     squid:S00100  
Method names should comply with a naming convention
Split this 122 characters long line (which is greater than 120 authorized).     NEW     squid:S00103  
Lines should not be too long
357
        try {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
358
            SecretKeySpec keySpec = new SecretKeySpec(key, algorithm);
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
359
            Cipher cipher = Cipher.getInstance(transformation);
360
            SecureRandom random = new SecureRandom();
361
            cipher.init(isEncrypt ? Cipher.ENCRYPT_MODE : Cipher.DECRYPT_MODE, keySpec, random);
Convert this usage of the ternary operator to an "if"/"else" structure.     NEW     squid:S1774  
The ternary operator should not be used
362
            return cipher.doFinal(data);
363
        } catch (Throwable e) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "catch" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
Either log or rethrow this exception.     NEW     squid:S1166  
Exception handlers should preserve the original exceptions
Catch Exception instead of Throwable.     NEW     squid:S1181  
Throwable and Error should not be caught
364
            e.printStackTrace();
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Use a logger to log this exception.     NEW     squid:S1148  
Throwable.printStackTrace(...) should not be called
365
        }
366
        return null;
Return an empty array instead of null.     NEW     squid:S1168  
Empty arrays and collections should be returned instead of null
367
    }
368

                  
374
     * @return Base64密文
375
     */
376
    public static byte[] encryptDES2Base64(byte[] data, byte[] key) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
377
        return EncodeUtils.base64Encode(encryptDES(data, key));
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
378
    }
379

                  
385
     * @return 16进制密文
386
     */
387
    public static String encryptDES2HexString(byte[] data, byte[] key) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
388
        return bytes2HexString(encryptDES(data, key));
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
389
    }
390

                  
396
     * @return 密文
397
     */
398
    public static byte[] encryptDES(byte[] data, byte[] key) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
399
        return DESTemplet(data, key, DES_Algorithm, DES_Transformation, true);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
400
    }
401

                  
407
     * @return 明文
408
     */
409
    public static byte[] decryptBase64DES(byte[] data, byte[] key) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
410
        return decryptDES(EncodeUtils.base64Decode(data), key);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
411
    }
412

                  
418
     * @return 明文
419
     */
420
    public static byte[] decryptHexStringDES(String data, byte[] key) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
421
        return decryptDES(hexString2Bytes(data), key);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
422
    }
423

                  
429
     * @return 明文
430
     */
431
    public static byte[] decryptDES(byte[] data, byte[] key) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
432
        return DESTemplet(data, key, DES_Algorithm, DES_Transformation, false);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
433
    }
434

                  
440
     * <p>填充方式有:NoPadding、ZerosPadding、PKCS5Padding</p>
441
     */
442
    public static String TripleDES_Transformation = "DESede/ECB/NoPadding";
Rename this field "TripleDES_Transformation" to match the regular expression '^[a-z][a-zA-Z0-9]*$'.     NEW     squid:S3008  
Static non-final field names should comply with a naming convention
Make this "public static TripleDES_Transformation" field final     NEW     squid:S1444  
"public static" fields should be constant
Move this variable to comply with Java Code Conventions.     NEW     squid:S1213  
The members of an interface declaration or class should appear in a pre-defined order
Make TripleDES_Transformation a static final constant or non-public and provide accessors if needed.     NEW     squid:ClassVariableVisibilityCheck  
Class variable fields should not have public accessibility
443
    private static final String TripleDES_Algorithm = "DESede";
Move this variable to comply with Java Code Conventions.     NEW     squid:S1213  
The members of an interface declaration or class should appear in a pre-defined order
Rename this constant name to match the regular expression '^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$'.     NEW     squid:S00115  
Constant names should comply with a naming convention
444

                  
445

                  
451
     * @return Base64密文
452
     */
453
    public static byte[] encrypt3DES2Base64(byte[] data, byte[] key) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
454
        return EncodeUtils.base64Encode(encrypt3DES(data, key));
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
455
    }
456

                  
462
     * @return 16进制密文
463
     */
464
    public static String encrypt3DES2HexString(byte[] data, byte[] key) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
465
        return bytes2HexString(encrypt3DES(data, key));
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
466
    }
467

                  
473
     * @return 密文
474
     */
475
    public static byte[] encrypt3DES(byte[] data, byte[] key) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
476
        return DESTemplet(data, key, TripleDES_Algorithm, TripleDES_Transformation, true);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
477
    }
478

                  
484
     * @return 明文
485
     */
486
    public static byte[] decryptBase64_3DES(byte[] data, byte[] key) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Rename this method name to match the regular expression '^[a-z][a-zA-Z0-9]*$'.     NEW     squid:S00100  
Method names should comply with a naming convention
487
        return decrypt3DES(EncodeUtils.base64Decode(data), key);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
488
    }
489

                  
495
     * @return 明文
496
     */
497
    public static byte[] decryptHexString3DES(String data, byte[] key) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
498
        return decrypt3DES(hexString2Bytes(data), key);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
499
    }
500

                  
506
     * @return 明文
507
     */
508
    public static byte[] decrypt3DES(byte[] data, byte[] key) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
509
        return DESTemplet(data, key, TripleDES_Algorithm, TripleDES_Transformation, false);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
510
    }
511

                  
517
     * <p>填充方式有:NoPadding、ZerosPadding、PKCS5Padding</p>
518
     */
519
    public static String AES_Transformation = "AES/ECB/NoPadding";
Rename this field "AES_Transformation" to match the regular expression '^[a-z][a-zA-Z0-9]*$'.     NEW     squid:S3008  
Static non-final field names should comply with a naming convention
Make this "public static AES_Transformation" field final     NEW     squid:S1444  
"public static" fields should be constant
Move this variable to comply with Java Code Conventions.     NEW     squid:S1213  
The members of an interface declaration or class should appear in a pre-defined order
Make AES_Transformation a static final constant or non-public and provide accessors if needed.     NEW     squid:ClassVariableVisibilityCheck  
Class variable fields should not have public accessibility
520
    private static final String AES_Algorithm = "AES";
Move this variable to comply with Java Code Conventions.     NEW     squid:S1213  
The members of an interface declaration or class should appear in a pre-defined order
Rename this constant name to match the regular expression '^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$'.     NEW     squid:S00115  
Constant names should comply with a naming convention
521

                  
522

                  
528
     * @return Base64密文
529
     */
530
    public static byte[] encryptAES2Base64(byte[] data, byte[] key) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
531
        return EncodeUtils.base64Encode(encryptAES(data, key));
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
532
    }
533

                  
539
     * @return 16进制密文
540
     */
541
    public static String encryptAES2HexString(byte[] data, byte[] key) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
542
        return bytes2HexString(encryptAES(data, key));
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
543
    }
544

                  
550
     * @return 密文
551
     */
552
    public static byte[] encryptAES(byte[] data, byte[] key) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
553
        return DESTemplet(data, key, AES_Algorithm, AES_Transformation, true);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
554
    }
555

                  
561
     * @return 明文
562
     */
563
    public static byte[] decryptBase64AES(byte[] data, byte[] key) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
564
        return decryptAES(EncodeUtils.base64Decode(data), key);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
565
    }
566

                  
572
     * @return 明文
573
     */
574
    public static byte[] decryptHexStringAES(String data, byte[] key) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
575
        return decryptAES(hexString2Bytes(data), key);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
576
    }
577

                  
583
     * @return 明文
584
     */
585
    public static byte[] decryptAES(byte[] data, byte[] key) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
586
        return DESTemplet(data, key, AES_Algorithm, AES_Transformation, false);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
587
    }
588
}
547
New issues
Add or update the header of this file.     NEW     squid:S1451
Copyright and license headers should be defined
This file has 1,141 lines, which is greater than 1,000 authorized. Split it into smaller files.     NEW     squid:S00104
Files should not have too many lines
Add a new line at the end of this file.     NEW     squid:S00113
Files should contain an empty new line at the end
1
package com.blankj.utilcode.utils;
2

                  
30
 * </pre>
31
 */
32
public class FileUtils {
Make this class "final" or add a public constructor.     NEW     squid:S2974  
Classes without "public" constructors should be "final"
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
class "FileUtils" has 75 methods, which is greater than the 35 authorized. Split it into smaller classes.     NEW     squid:S1448  
Classes should not have too many methods
The Cyclomatic Complexity of this class is 310 which is greater than 200 authorized.     NEW     squid:ClassCyclomaticComplexity  
Classes should not be too complex
33

                  
34
    private FileUtils() {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Make this line start at column 3.     NEW     squid:IndentationCheck  
Source code should be indented consistently
35
        throw new UnsupportedOperationException("u can't instantiate me...");
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
36
    }
37

                  
42
     * @return 文件
43
     */
44
    public static File getFileByPath(String filePath) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
45
        return StringUtils.isSpace(filePath) ? null : new File(filePath);
Convert this usage of the ternary operator to an "if"/"else" structure.     NEW     squid:S1774  
The ternary operator should not be used
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
46
    }
47

                  
52
     * @return {@code true}: 存在<br>{@code false}: 不存在
53
     */
54
    public static boolean isFileExists(String filePath) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
55
        return isFileExists(getFileByPath(filePath));
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
56
    }
57

                  
62
     * @return {@code true}: 存在<br>{@code false}: 不存在
63
     */
64
    public static boolean isFileExists(File file) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
65
        return file != null && file.exists();
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
66
    }
67

                  
72
     * @return {@code true}: 是<br>{@code false}: 否
73
     */
74
    public static boolean isDir(String dirPath) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
75
        return isDir(getFileByPath(dirPath));
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
76
    }
77

                  
82
     * @return {@code true}: 是<br>{@code false}: 否
83
     */
84
    public static boolean isDir(File file) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
85
        return isFileExists(file) && file.isDirectory();
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
86
    }
87

                  
92
     * @return {@code true}: 是<br>{@code false}: 否
93
     */
94
    public static boolean isFile(String filePath) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
95
        return isFile(getFileByPath(filePath));
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
96
    }
97

                  
102
     * @return {@code true}: 是<br>{@code false}: 否
103
     */
104
    public static boolean isFile(File file) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
105
        return isFileExists(file) && file.isFile();
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
106
    }
107

                  
112
     * @return {@code true}: 存在或创建成功<br>{@code false}: 不存在或创建失败
113
     */
114
    public static boolean createOrExistsDir(String dirPath) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
115
        return createOrExistsDir(getFileByPath(dirPath));
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
116
    }
117

                  
122
     * @return {@code true}: 存在或创建成功<br>{@code false}: 不存在或创建失败
123
     */
124
    public static boolean createOrExistsDir(File file) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
125
        // 如果存在,是目录则返回true,是文件则返回false,不存在则返回是否创建成功
126
        return file != null && (file.exists() ? file.isDirectory() : file.mkdirs());
Convert this usage of the ternary operator to an "if"/"else" structure.     NEW     squid:S1774  
The ternary operator should not be used
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
127
    }
128

                  
133
     * @return {@code true}: 存在或创建成功<br>{@code false}: 不存在或创建失败
134
     */
135
    public static boolean createOrExistsFile(String filePath) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
136
        return createOrExistsFile(getFileByPath(filePath));
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
137
    }
138

                  
143
     * @return {@code true}: 存在或创建成功<br>{@code false}: 不存在或创建失败
144
     */
145
    public static boolean createOrExistsFile(File file) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Reduce the number of returns of this method 5, down to the maximum allowed 3.     NEW     squid:S1142  
Methods should not have too many return statements
146
        if (file == null) return false;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
147
        // 如果存在,是文件则返回true,是目录则返回false
148
        if (file.exists()) return file.isFile();
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
149
        if (!createOrExistsDir(file.getParentFile())) return false;
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
150
        try {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
151
            return file.createNewFile();
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
152
        } catch (IOException e) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "catch" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
Either log or rethrow this exception.     NEW     squid:S1166  
Exception handlers should preserve the original exceptions
153
            e.printStackTrace();
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Use a logger to log this exception.     NEW     squid:S1148  
Throwable.printStackTrace(...) should not be called
154
            return false;
155
        }
162
     * @return {@code true}: 创建成功<br>{@code false}: 创建失败
163
     */
164
    public static boolean createFileByDeleteOldFile(String filePath) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
165
        return createFileByDeleteOldFile(getFileByPath(filePath));
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
166
    }
167

                  
172
     * @return {@code true}: 创建成功<br>{@code false}: 创建失败
173
     */
174
    public static boolean createFileByDeleteOldFile(File file) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Reduce the number of returns of this method 5, down to the maximum allowed 3.     NEW     squid:S1142  
Methods should not have too many return statements
The Cyclomatic Complexity of this method "createFileByDeleteOldFile" is 12 which is greater than 10 authorized.     NEW     squid:MethodCyclomaticComplexity  
Methods should not be too complex
175
        if (file == null) return false;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
176
        // 文件存在并且删除失败返回false
177
        if (file.exists() && file.isFile() && !file.delete()) return false;
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
178
        // 创建目录失败返回false
179
        if (!createOrExistsDir(file.getParentFile())) return false;
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
180
        try {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
181
            return file.createNewFile();
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
182
        } catch (IOException e) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "catch" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
Either log or rethrow this exception.     NEW     squid:S1166  
Exception handlers should preserve the original exceptions
183
            e.printStackTrace();
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Use a logger to log this exception.     NEW     squid:S1148  
Throwable.printStackTrace(...) should not be called
184
            return false;
185
        }
194
     * @return {@code true}: 复制或移动成功<br>{@code false}: 复制或移动失败
195
     */
196
    private static boolean copyOrMoveDir(String srcDirPath, String destDirPath, boolean isMove) {
Remove this unused private "copyOrMoveDir" method.     NEW     squid:UnusedPrivateMethod  
Unused "private" methods should be removed
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
197
        return copyOrMoveDir(getFileByPath(srcDirPath), getFileByPath(destDirPath), isMove);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
198
    }
199

                  
206
     * @return {@code true}: 复制或移动成功<br>{@code false}: 复制或移动失败
207
     */
208
    private static boolean copyOrMoveDir(File srcDir, File destDir, boolean isMove) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Reduce the number of returns of this method 7, down to the maximum allowed 3.     NEW     squid:S1142  
Methods should not have too many return statements
The Cyclomatic Complexity of this method "copyOrMoveDir" is 19 which is greater than 10 authorized.     NEW     squid:MethodCyclomaticComplexity  
Methods should not be too complex
209
        if (srcDir == null || destDir == null) return false;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
210
        // 如果目标目录在源目录中则返回false,看不懂的话好好想想递归怎么结束
211
        // srcPath : F:\\MyGithub\\AndroidUtilCode\\utilcode\\src\\test\\res
214
        String srcPath = srcDir.getPath() + File.separator;
215
        String destPath = destDir.getPath() + File.separator;
216
        if (destPath.contains(srcPath)) return false;
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
217
        // 源文件不存在或者不是目录则返回false
218
        if (!srcDir.exists() || !srcDir.isDirectory()) return false;
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
219
        // 目标目录不存在返回false
220
        if (!createOrExistsDir(destDir)) return false;
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
221
        File[] files = srcDir.listFiles();
222
        for (File file : files) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
223
            File oneDestFile = new File(destPath + file.getName());
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
224
            if (file.isFile()) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
225
                // 如果操作失败返回false
226
                if (!copyOrMoveFile(file, oneDestFile, isMove)) return false;
Make this line start at column 9.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
227
            } else if (file.isDirectory()) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "else" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
228
                // 如果操作失败返回false
229
                if (!copyOrMoveDir(file, oneDestFile, isMove)) return false;
Merge this if statement with the enclosing one.     NEW     squid:S1066  
Collapsible "if" statements should be merged
Make this line start at column 9.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
230
            }
231
        }
241
     * @return {@code true}: 复制或移动成功<br>{@code false}: 复制或移动失败
242
     */
243
    private static boolean copyOrMoveFile(String srcFilePath, String destFilePath, boolean isMove) {
Remove this unused private "copyOrMoveFile" method.     NEW     squid:UnusedPrivateMethod  
Unused "private" methods should be removed
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
244
        return copyOrMoveFile(getFileByPath(srcFilePath), getFileByPath(destFilePath), isMove);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
245
    }
246

                  
253
     * @return {@code true}: 复制或移动成功<br>{@code false}: 复制或移动失败
254
     */
255
    private static boolean copyOrMoveFile(File srcFile, File destFile, boolean isMove) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Reduce the number of returns of this method 6, down to the maximum allowed 3.     NEW     squid:S1142  
Methods should not have too many return statements
The Cyclomatic Complexity of this method "copyOrMoveFile" is 17 which is greater than 10 authorized.     NEW     squid:MethodCyclomaticComplexity  
Methods should not be too complex
256
        if (srcFile == null || destFile == null) return false;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
257
        // 源文件不存在或者不是文件则返回false
258
        if (!srcFile.exists() || !srcFile.isFile()) return false;
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
259
        // 目标文件存在且是文件则返回false
260
        if (destFile.exists() && destFile.isFile()) return false;
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
261
        // 目标目录不存在返回false
262
        if (!createOrExistsDir(destFile.getParentFile())) return false;
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
263
        try {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
264
            return writeFileFromIS(destFile, new FileInputStream(srcFile), false)
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
265
                    && !(isMove && !deleteFile(srcFile));
266
        } catch (FileNotFoundException e) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "catch" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
Either log or rethrow this exception.     NEW     squid:S1166  
Exception handlers should preserve the original exceptions
267
            e.printStackTrace();
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Use a logger to log this exception.     NEW     squid:S1148  
Throwable.printStackTrace(...) should not be called
268
            return false;
269
        }
277
     * @return {@code true}: 复制成功<br>{@code false}: 复制失败
278
     */
279
    public static boolean copyDir(String srcDirPath, String destDirPath) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
280
        return copyDir(getFileByPath(srcDirPath), getFileByPath(destDirPath));
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
281
    }
282

                  
288
     * @return {@code true}: 复制成功<br>{@code false}: 复制失败
289
     */
290
    public static boolean copyDir(File srcDir, File destDir) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
291
        return copyOrMoveDir(srcDir, destDir, false);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
292
    }
293

                  
299
     * @return {@code true}: 复制成功<br>{@code false}: 复制失败
300
     */
301
    public static boolean copyFile(String srcFilePath, String destFilePath) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
302
        return copyFile(getFileByPath(srcFilePath), getFileByPath(destFilePath));
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
303
    }
304

                  
310
     * @return {@code true}: 复制成功<br>{@code false}: 复制失败
311
     */
312
    public static boolean copyFile(File srcFile, File destFile) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
313
        return copyOrMoveFile(srcFile, destFile, false);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
314
    }
315

                  
321
     * @return {@code true}: 移动成功<br>{@code false}: 移动失败
322
     */
323
    public static boolean moveDir(String srcDirPath, String destDirPath) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
324
        return moveDir(getFileByPath(srcDirPath), getFileByPath(destDirPath));
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
325
    }
326

                  
332
     * @return {@code true}: 移动成功<br>{@code false}: 移动失败
333
     */
334
    public static boolean moveDir(File srcDir, File destDir) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
335
        return copyOrMoveDir(srcDir, destDir, true);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
336
    }
337

                  
343
     * @return {@code true}: 移动成功<br>{@code false}: 移动失败
344
     */
345
    public static boolean moveFile(String srcFilePath, String destFilePath) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
346
        return moveFile(getFileByPath(srcFilePath), getFileByPath(destFilePath));
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
347
    }
348

                  
354
     * @return {@code true}: 移动成功<br>{@code false}: 移动失败
355
     */
356
    public static boolean moveFile(File srcFile, File destFile) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
357
        return copyOrMoveFile(srcFile, destFile, true);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
358
    }
359

                  
364
     * @return {@code true}: 删除成功<br>{@code false}: 删除失败
365
     */
366
    public static boolean deleteDir(String dirPath) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
367
        return deleteDir(getFileByPath(dirPath));
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
368
    }
369

                  
374
     * @return {@code true}: 删除成功<br>{@code false}: 删除失败
375
     */
376
    public static boolean deleteDir(File dir) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Reduce the number of returns of this method 6, down to the maximum allowed 3.     NEW     squid:S1142  
Methods should not have too many return statements
The Cyclomatic Complexity of this method "deleteDir" is 16 which is greater than 10 authorized.     NEW     squid:MethodCyclomaticComplexity  
Methods should not be too complex
377
        if (dir == null) return false;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
378
        // 目录不存在返回true
379
        if (!dir.exists()) return true;
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
380
        // 不是目录返回false
381
        if (!dir.isDirectory()) return false;
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
382
        // 现在文件存在且是文件夹
383
        File[] files = dir.listFiles();
384
        if (files != null && files.length != 0) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
385
            for (File file : files) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
386
                if (file.isFile()) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Make this line start at column 9.     NEW     squid:IndentationCheck  
Source code should be indented consistently
387
                    if (!deleteFile(file)) return false;
Make this line start at column 11.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Refactor this code to not nest more than 3 if/for/while/switch/try statements.     NEW     squid:S134  
Control flow statements "if", "for", "while", "switch" and "try" should not be nested too deeply
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
388
                } else if (file.isDirectory()) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "else" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
389
                    if (!deleteDir(file)) return false;
Merge this if statement with the enclosing one.     NEW     squid:S1066  
Collapsible "if" statements should be merged
Make this line start at column 11.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Refactor this code to not nest more than 3 if/for/while/switch/try statements.     NEW     squid:S134  
Control flow statements "if", "for", "while", "switch" and "try" should not be nested too deeply
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
390
                }
391
            }
400
     * @return {@code true}: 删除成功<br>{@code false}: 删除失败
401
     */
402
    public static boolean deleteFile(String srcFilePath) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
403
        return deleteFile(getFileByPath(srcFilePath));
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
404
    }
405

                  
410
     * @return {@code true}: 删除成功<br>{@code false}: 删除失败
411
     */
412
    public static boolean deleteFile(File file) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
413
        return file != null && (!file.exists() || file.isFile() && file.delete());
Add parentheses to make the operator precedence explicit.     NEW     squid:S864  
Limited dependence should be placed on operator precedence rules in expressions
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
414
    }
415

                  
420
     * @return {@code true}: 删除成功<br>{@code false}: 删除失败
421
     */
422
    public static boolean deleteFilesInDir(String dirPath) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
423
        return deleteFilesInDir(getFileByPath(dirPath));
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
424
    }
425

                  
430
     * @return {@code true}: 删除成功<br>{@code false}: 删除失败
431
     */
432
    public static boolean deleteFilesInDir(File dir) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Reduce the number of returns of this method 6, down to the maximum allowed 3.     NEW     squid:S1142  
Methods should not have too many return statements
The Cyclomatic Complexity of this method "deleteFilesInDir" is 16 which is greater than 10 authorized.     NEW     squid:MethodCyclomaticComplexity  
Methods should not be too complex
433
        if (dir == null) return false;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
434
        // 目录不存在返回true
435
        if (!dir.exists()) return true;
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
436
        // 不是目录返回false
437
        if (!dir.isDirectory()) return false;
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
438
        // 现在文件存在且是文件夹
439
        File[] files = dir.listFiles();
440
        if (files != null && files.length != 0) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
441
            for (File file : files) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
442
                if (file.isFile()) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Make this line start at column 9.     NEW     squid:IndentationCheck  
Source code should be indented consistently
443
                    if (!deleteFile(file)) return false;
Make this line start at column 11.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Refactor this code to not nest more than 3 if/for/while/switch/try statements.     NEW     squid:S134  
Control flow statements "if", "for", "while", "switch" and "try" should not be nested too deeply
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
444
                } else if (file.isDirectory()) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "else" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
445
                    if (!deleteDir(file)) return false;
Merge this if statement with the enclosing one.     NEW     squid:S1066  
Collapsible "if" statements should be merged
Make this line start at column 11.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Refactor this code to not nest more than 3 if/for/while/switch/try statements.     NEW     squid:S134  
Control flow statements "if", "for", "while", "switch" and "try" should not be nested too deeply
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
446
                }
447
            }
457
     * @return 文件链表
458
     */
459
    public static List<File> listFilesInDir(String dirPath, boolean isRecursive) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
460
        return listFilesInDir(getFileByPath(dirPath), isRecursive);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
461
    }
462

                  
468
     * @return 文件链表
469
     */
470
    public static List<File> listFilesInDir(File dir, boolean isRecursive) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Provide multiple methods instead of using "isRecursive" to determine which action to take.     NEW     squid:S2301  
Public methods should not contain selector arguments
471
        if (isRecursive) return listFilesInDir(dir);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
472
        if (dir == null || !isDir(dir)) return null;
Return an empty collection instead of null.     NEW     squid:S1168  
Empty arrays and collections should be returned instead of null
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
473
        List<File> list = new ArrayList<>();
474
        Collections.addAll(list, dir.listFiles());
482
     * @return 文件链表
483
     */
484
    public static List<File> listFilesInDir(String dirPath) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
485
        return listFilesInDir(getFileByPath(dirPath));
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
486
    }
487

                  
492
     * @return 文件链表
493
     */
494
    public static List<File> listFilesInDir(File dir) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
495
        if (dir == null || !isDir(dir)) return null;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Return an empty collection instead of null.     NEW     squid:S1168  
Empty arrays and collections should be returned instead of null
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
496
        List<File> list = new ArrayList<>();
497
        File[] files = dir.listFiles();
498
        if (files != null && files.length != 0) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
499
            for (File file : files) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
500
                list.add(file);
Make this line start at column 9.     NEW     squid:IndentationCheck  
Source code should be indented consistently
501
                if (file.isDirectory()) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
502
                    list.addAll(listFilesInDir(file));
Make this line start at column 11.     NEW     squid:IndentationCheck  
Source code should be indented consistently
503
                }
504
            }
516
     * @return 文件链表
517
     */
518
    public static List<File> listFilesInDirWithFilter(String dirPath, String suffix, boolean isRecursive) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
519
        return listFilesInDirWithFilter(getFileByPath(dirPath), suffix, isRecursive);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
520
    }
521

                  
529
     * @return 文件链表
530
     */
531
    public static List<File> listFilesInDirWithFilter(File dir, String suffix, boolean isRecursive) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Provide multiple methods instead of using "isRecursive" to determine which action to take.     NEW     squid:S2301  
Public methods should not contain selector arguments
532
        if (isRecursive) return listFilesInDirWithFilter(dir, suffix);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
533
        if (dir == null || !isDir(dir)) return null;
Return an empty collection instead of null.     NEW     squid:S1168  
Empty arrays and collections should be returned instead of null
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
534
        List<File> list = new ArrayList<>();
535
        File[] files = dir.listFiles();
536
        if (files != null && files.length != 0) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
537
            for (File file : files) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
538
                if (file.getName().toUpperCase().endsWith(suffix.toUpperCase())) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Define the locale to be used in this String operation.     NEW     squid:S1449  
Locale should be used in String operations
Define the locale to be used in this String operation.     NEW     squid:S1449  
Locale should be used in String operations
Make this line start at column 9.     NEW     squid:IndentationCheck  
Source code should be indented consistently
539
                    list.add(file);
Make this line start at column 11.     NEW     squid:IndentationCheck  
Source code should be indented consistently
540
                }
541
            }
552
     * @return 文件链表
553
     */
554
    public static List<File> listFilesInDirWithFilter(String dirPath, String suffix) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
555
        return listFilesInDirWithFilter(getFileByPath(dirPath), suffix);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
556
    }
557

                  
564
     * @return 文件链表
565
     */
566
    public static List<File> listFilesInDirWithFilter(File dir, String suffix) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
567
        if (dir == null || !isDir(dir)) return null;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Return an empty collection instead of null.     NEW     squid:S1168  
Empty arrays and collections should be returned instead of null
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
568
        List<File> list = new ArrayList<>();
569
        File[] files = dir.listFiles();
570
        if (files != null && files.length != 0) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
571
            for (File file : files) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
572
                if (file.getName().toUpperCase().endsWith(suffix.toUpperCase())) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Define the locale to be used in this String operation.     NEW     squid:S1449  
Locale should be used in String operations
Define the locale to be used in this String operation.     NEW     squid:S1449  
Locale should be used in String operations
Make this line start at column 9.     NEW     squid:IndentationCheck  
Source code should be indented consistently
573
                    list.add(file);
Make this line start at column 11.     NEW     squid:IndentationCheck  
Source code should be indented consistently
574
                }
575
                if (file.isDirectory()) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
576
                    list.addAll(listFilesInDirWithFilter(file, suffix));
Make this line start at column 11.     NEW     squid:IndentationCheck  
Source code should be indented consistently
577
                }
578
            }
589
     * @return 文件链表
590
     */
591
    public static List<File> listFilesInDirWithFilter(String dirPath, FilenameFilter filter, boolean isRecursive) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
592
        return listFilesInDirWithFilter(getFileByPath(dirPath), filter, isRecursive);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
593
    }
594

                  
601
     * @return 文件链表
602
     */
603
    public static List<File> listFilesInDirWithFilter(File dir, FilenameFilter filter, boolean isRecursive) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Provide multiple methods instead of using "isRecursive" to determine which action to take.     NEW     squid:S2301  
Public methods should not contain selector arguments
604
        if (isRecursive) return listFilesInDirWithFilter(dir, filter);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
605
        if (dir == null || !isDir(dir)) return null;
Return an empty collection instead of null.     NEW     squid:S1168  
Empty arrays and collections should be returned instead of null
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
606
        List<File> list = new ArrayList<>();
607
        File[] files = dir.listFiles();
608
        if (files != null && files.length != 0) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
609
            for (File file : files) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
610
                if (filter.accept(file.getParentFile(), file.getName())) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Make this line start at column 9.     NEW     squid:IndentationCheck  
Source code should be indented consistently
611
                    list.add(file);
Make this line start at column 11.     NEW     squid:IndentationCheck  
Source code should be indented consistently
612
                }
613
            }
623
     * @return 文件链表
624
     */
625
    public static List<File> listFilesInDirWithFilter(String dirPath, FilenameFilter filter) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
626
        return listFilesInDirWithFilter(getFileByPath(dirPath), filter);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
627
    }
628

                  
634
     * @return 文件链表
635
     */
636
    public static List<File> listFilesInDirWithFilter(File dir, FilenameFilter filter) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
637
        if (dir == null || !isDir(dir)) return null;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Return an empty collection instead of null.     NEW     squid:S1168  
Empty arrays and collections should be returned instead of null
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
638
        List<File> list = new ArrayList<>();
639
        File[] files = dir.listFiles();
640
        if (files != null && files.length != 0) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
641
            for (File file : files) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
642
                if (filter.accept(file.getParentFile(), file.getName())) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Make this line start at column 9.     NEW     squid:IndentationCheck  
Source code should be indented consistently
643
                    list.add(file);
Make this line start at column 11.     NEW     squid:IndentationCheck  
Source code should be indented consistently
644
                }
645
                if (file.isDirectory()) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
646
                    list.addAll(listFilesInDirWithFilter(file, filter));
Make this line start at column 11.     NEW     squid:IndentationCheck  
Source code should be indented consistently
647
                }
648
            }
659
     * @return 文件链表
660
     */
661
    public static List<File> searchFileInDir(String dirPath, String fileName) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
662
        return searchFileInDir(getFileByPath(dirPath), fileName);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
663
    }
664

                  
671
     * @return 文件链表
672
     */
673
    public static List<File> searchFileInDir(File dir, String fileName) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
674
        if (dir == null || !isDir(dir)) return null;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Return an empty collection instead of null.     NEW     squid:S1168  
Empty arrays and collections should be returned instead of null
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
675
        List<File> list = new ArrayList<>();
676
        File[] files = dir.listFiles();
677
        if (files != null && files.length != 0) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
678
            for (File file : files) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
679
                if (file.getName().toUpperCase().equals(fileName.toUpperCase())) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Define the locale to be used in this String operation.     NEW     squid:S1449  
Locale should be used in String operations
Define the locale to be used in this String operation.     NEW     squid:S1449  
Locale should be used in String operations
Make this line start at column 9.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Replace these toUpperCase()/toLowerCase() and equals() calls with a single equalsIgnoreCase() call.     NEW     squid:S1157  
Case insensitive string comparisons should be made without intermediate upper or lower casing
680
                    list.add(file);
Make this line start at column 11.     NEW     squid:IndentationCheck  
Source code should be indented consistently
681
                }
682
                if (file.isDirectory()) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
683
                    list.addAll(searchFileInDir(file, fileName));
Make this line start at column 11.     NEW     squid:IndentationCheck  
Source code should be indented consistently
684
                }
685
            }
696
     * @return {@code true}: 写入成功<br>{@code false}: 写入失败
697
     */
698
    public static boolean writeFileFromIS(String filePath, InputStream is, boolean append) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
699
        return writeFileFromIS(getFileByPath(filePath), is, append);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
700
    }
701

                  
708
     * @return {@code true}: 写入成功<br>{@code false}: 写入失败
709
     */
710
    public static boolean writeFileFromIS(File file, InputStream is, boolean append) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Reduce the number of returns of this method 4, down to the maximum allowed 3.     NEW     squid:S1142  
Methods should not have too many return statements
711
        if (file == null || is == null) return false;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
712
        if (!createOrExistsFile(file)) return false;
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
713
        OutputStream os = null;
714
        try {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Change this "try" to a try-with-resources. (sonar.java.source not set. Assuming 7 or greater.)     NEW     squid:S2093  
Try-with-resources should be used
715
            os = new BufferedOutputStream(new FileOutputStream(file, append));
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Close this "FileOutputStream".     NEW     squid:S2095  
Resources should be closed
716
            byte data[] = new byte[KB];
Move the array designator from the variable to the type.     NEW     squid:S1197  
Array designators "[]" should be on the type, not the variable
717
            int len;
718
            while ((len = is.read(data, 0, KB)) != -1) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
719
                os.write(data, 0, len);
Make this line start at column 9.     NEW     squid:IndentationCheck  
Source code should be indented consistently
720
            }
721
            return true;
722
        } catch (IOException e) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "catch" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
Either log or rethrow this exception.     NEW     squid:S1166  
Exception handlers should preserve the original exceptions
723
            e.printStackTrace();
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Use a logger to log this exception.     NEW     squid:S1148  
Throwable.printStackTrace(...) should not be called
724
            return false;
725
        } finally {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "finally" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
726
            closeIO(is, os);
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
727
        }
728
    }
736
     * @return {@code true}: 写入成功<br>{@code false}: 写入失败
737
     */
738
    public static boolean writeFileFromString(String filePath, String content, boolean append) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
739
        return writeFileFromString(getFileByPath(filePath), content, append);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
740
    }
741

                  
748
     * @return {@code true}: 写入成功<br>{@code false}: 写入失败
749
     */
750
    public static boolean writeFileFromString(File file, String content, boolean append) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Reduce the number of returns of this method 4, down to the maximum allowed 3.     NEW     squid:S1142  
Methods should not have too many return statements
751
        if (file == null || content == null) return false;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
752
        if (!createOrExistsFile(file)) return false;
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
753
        FileWriter fileWriter = null;
Remove this use of "java.io.FileWriter"     NEW     squid:S1943  
Classes and methods that rely on the default system encoding should not be used
754
        try {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Change this "try" to a try-with-resources. (sonar.java.source not set. Assuming 7 or greater.)     NEW     squid:S2093  
Try-with-resources should be used
755
            fileWriter = new FileWriter(file, append);
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Remove this use of constructor "FileWriter(File,boolean)"     NEW     squid:S1943  
Classes and methods that rely on the default system encoding should not be used
756
            fileWriter.write(content);
757
            return true;
758
        } catch (IOException e) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "catch" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
Either log or rethrow this exception.     NEW     squid:S1166  
Exception handlers should preserve the original exceptions
759
            e.printStackTrace();
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Use a logger to log this exception.     NEW     squid:S1148  
Throwable.printStackTrace(...) should not be called
760
            return false;
761
        } finally {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "finally" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
762
            closeIO(fileWriter);
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
763
        }
764
    }
771
     * @return 文件行链表
772
     */
773
    public static List<String> readFile2List(String filePath, String charsetName) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
774
        return readFile2List(getFileByPath(filePath), charsetName);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
775
    }
776

                  
782
     * @return 文件行链表
783
     */
784
    public static List<String> readFile2List(File file, String charsetName) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
785
        return readFile2List(file, 0, 0x7FFFFFFF, charsetName);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
786
    }
787

                  
796
     */
797
    public static List<String> readFile2List(String filePath, int st, int end, String
798
            charsetName) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
799
        return readFile2List(getFileByPath(filePath), st, end, charsetName);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
800
    }
801

                  
809
     * @return 包含从start行到end行的list
810
     */
811
    public static List<String> readFile2List(File file, int st, int end, String charsetName) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Reduce the number of returns of this method 4, down to the maximum allowed 3.     NEW     squid:S1142  
Methods should not have too many return statements
The Cyclomatic Complexity of this method "readFile2List" is 13 which is greater than 10 authorized.     NEW     squid:MethodCyclomaticComplexity  
Methods should not be too complex
812
        if (file == null) return null;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Return an empty collection instead of null.     NEW     squid:S1168  
Empty arrays and collections should be returned instead of null
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
813
        if (st > end) return null;
Return an empty collection instead of null.     NEW     squid:S1168  
Empty arrays and collections should be returned instead of null
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
814
        BufferedReader reader = null;
815
        try {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Change this "try" to a try-with-resources. (sonar.java.source not set. Assuming 7 or greater.)     NEW     squid:S2093  
Try-with-resources should be used
816
            String line;
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
817
            int curLine = 1;
818
            List<String> list = new ArrayList<>();
819
            if (StringUtils.isSpace(charsetName)) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
820
                reader = new BufferedReader(new FileReader(file));
Make this line start at column 9.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Close this "FileReader".     NEW     squid:S2095  
Resources should be closed
Remove this use of constructor "FileReader(File)"     NEW     squid:S1943  
Classes and methods that rely on the default system encoding should not be used
821
            } else {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "else" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
822
                reader = new BufferedReader(new InputStreamReader(new FileInputStream(file), charsetName));
Make this line start at column 9.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Close this "FileInputStream".     NEW     squid:S2095  
Resources should be closed
823
            }
824
            while ((line = reader.readLine()) != null) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
825
                if (curLine > end) break;
Make this line start at column 9.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
826
                if (st <= curLine && curLine <= end) list.add(line);
Change this condition so that it does not always evaluate to "true"     NEW     squid:S2583  
Conditions should not unconditionally evaluate to "TRUE" or to "FALSE"
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
827
                ++curLine;
828
            }
829
            return list;
830
        } catch (IOException e) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "catch" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
Either log or rethrow this exception.     NEW     squid:S1166  
Exception handlers should preserve the original exceptions
831
            e.printStackTrace();
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Use a logger to log this exception.     NEW     squid:S1148  
Throwable.printStackTrace(...) should not be called
832
            return null;
Return an empty collection instead of null.     NEW     squid:S1168  
Empty arrays and collections should be returned instead of null
833
        } finally {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "finally" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
834
            closeIO(reader);
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
835
        }
836
    }
843
     * @return 字符串
844
     */
845
    public static String readFile2String(String filePath, String charsetName) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
846
        return readFile2String(getFileByPath(filePath), charsetName);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
847
    }
848

                  
854
     * @return 字符串
855
     */
856
    public static String readFile2String(File file, String charsetName) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
857
        if (file == null) return null;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
858
        BufferedReader reader = null;
859
        try {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Change this "try" to a try-with-resources. (sonar.java.source not set. Assuming 7 or greater.)     NEW     squid:S2093  
Try-with-resources should be used
860
            StringBuilder sb = new StringBuilder();
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
861
            if (StringUtils.isSpace(charsetName)) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
862
                reader = new BufferedReader(new InputStreamReader(new FileInputStream(file)));
Make this line start at column 9.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Close this "FileInputStream".     NEW     squid:S2095  
Resources should be closed
Remove this use of constructor "InputStreamReader(InputStream)"     NEW     squid:S1943  
Classes and methods that rely on the default system encoding should not be used
863
            } else {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "else" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
864
                reader = new BufferedReader(new InputStreamReader(new FileInputStream(file), charsetName));
Make this line start at column 9.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Close this "FileInputStream".     NEW     squid:S2095  
Resources should be closed
865
            }
866
            String line;
867
            while ((line = reader.readLine()) != null) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
868
                sb.append(line).append("\r\n");// windows系统换行为\r\n,Linux为\n
Make this line start at column 9.     NEW     squid:IndentationCheck  
Source code should be indented consistently
869
            }
870
            // 要去除最后的换行符
871
            return sb.delete(sb.length() - 2, sb.length()).toString();
Assign this magic number 2 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
872
        } catch (IOException e) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "catch" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
Either log or rethrow this exception.     NEW     squid:S1166  
Exception handlers should preserve the original exceptions
873
            e.printStackTrace();
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Use a logger to log this exception.     NEW     squid:S1148  
Throwable.printStackTrace(...) should not be called
874
            return null;
875
        } finally {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "finally" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
876
            closeIO(reader);
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
877
        }
878
    }
884
     * @return 字符数组
885
     */
886
    public static byte[] readFile2Bytes(String filePath) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
887
        return readFile2Bytes(getFileByPath(filePath));
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
888
    }
889

                  
894
     * @return 字符数组
895
     */
896
    public static byte[] readFile2Bytes(File file) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
897
        if (file == null) return null;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Return an empty array instead of null.     NEW     squid:S1168  
Empty arrays and collections should be returned instead of null
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
898
        try {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
899
            return ConvertUtils.inputStream2Bytes(new FileInputStream(file));
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
900
        } catch (FileNotFoundException e) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "catch" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
Either log or rethrow this exception.     NEW     squid:S1166  
Exception handlers should preserve the original exceptions
901
            e.printStackTrace();
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Use a logger to log this exception.     NEW     squid:S1148  
Throwable.printStackTrace(...) should not be called
902
            return null;
Return an empty array instead of null.     NEW     squid:S1168  
Empty arrays and collections should be returned instead of null
903
        }
904
    }
910
     * @return 文件编码
911
     */
912
    public static String getFileCharsetSimple(String filePath) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
913
        return getFileCharsetSimple(getFileByPath(filePath));
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
914
    }
915

                  
920
     * @return 文件编码
921
     */
922
    public static String getFileCharsetSimple(File file) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Reduce the number of returns of this method 4, down to the maximum allowed 3.     NEW     squid:S1142  
Methods should not have too many return statements
923
        int p = 0;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
924
        InputStream is = null;
925
        try {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Change this "try" to a try-with-resources. (sonar.java.source not set. Assuming 7 or greater.)     NEW     squid:S2093  
Try-with-resources should be used
926
            is = new BufferedInputStream(new FileInputStream(file));
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Close this "FileInputStream".     NEW     squid:S2095  
Resources should be closed
927
            p = (is.read() << 8) + is.read();
Assign this magic number 8 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
928
        } catch (IOException e) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "catch" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
Either log or rethrow this exception.     NEW     squid:S1166  
Exception handlers should preserve the original exceptions
929
            e.printStackTrace();
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Use a logger to log this exception.     NEW     squid:S1148  
Throwable.printStackTrace(...) should not be called
930
        } finally {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "finally" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
931
            closeIO(is);
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
932
        }
933
        switch (p) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
934
            case 0xefbb:
935
                return "UTF-8";
Make this line start at column 9.     NEW     squid:IndentationCheck  
Source code should be indented consistently
936
            case 0xfffe:
937
                return "Unicode";
Make this line start at column 9.     NEW     squid:IndentationCheck  
Source code should be indented consistently
938
            case 0xfeff:
939
                return "UTF-16BE";
Make this line start at column 9.     NEW     squid:IndentationCheck  
Source code should be indented consistently
940
            default:
941
                return "GBK";
Make this line start at column 9.     NEW     squid:IndentationCheck  
Source code should be indented consistently
942
        }
943
    }
949
     * @return 文件行数
950
     */
951
    public static int getFileLines(String filePath) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
952
        return getFileLines(getFileByPath(filePath));
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
953
    }
954

                  
959
     * @return 文件行数
960
     */
961
    public static int getFileLines(File file) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
962
        int count = 1;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
963
        InputStream is = null;
964
        try {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Change this "try" to a try-with-resources. (sonar.java.source not set. Assuming 7 or greater.)     NEW     squid:S2093  
Try-with-resources should be used
965
            is = new BufferedInputStream(new FileInputStream(file));
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Close this "FileInputStream".     NEW     squid:S2095  
Resources should be closed
966
            byte[] buffer = new byte[KB];
967
            int readChars;
968
            while ((readChars = is.read(buffer, 0, KB)) != -1) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
969
                for (int i = 0; i < readChars; ++i) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Make this line start at column 9.     NEW     squid:IndentationCheck  
Source code should be indented consistently
970
                    if (buffer[i] == '\n') ++count;
Make this line start at column 11.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Refactor this code to not nest more than 3 if/for/while/switch/try statements.     NEW     squid:S134  
Control flow statements "if", "for", "while", "switch" and "try" should not be nested too deeply
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
971
                }
972
            }
973
        } catch (IOException e) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "catch" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
Either log or rethrow this exception.     NEW     squid:S1166  
Exception handlers should preserve the original exceptions
974
            e.printStackTrace();
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Use a logger to log this exception.     NEW     squid:S1148  
Throwable.printStackTrace(...) should not be called
975
        } finally {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "finally" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
976
            closeIO(is);
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
977
        }
978
        return count;
985
     * @return 文件大小
986
     */
987
    public static String getFileSize(String filePath) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
988
        return getFileSize(getFileByPath(filePath));
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
989
    }
990

                  
996
     * @return 文件大小
997
     */
998
    public static String getFileSize(File file) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
999
        if (!isFileExists(file)) return "";
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
1000
        return ConvertUtils.byte2FitSize(file.length());
1001
    }
1007
     * @return 文件的MD5校验码
1008
     */
1009
    public static String getFileMD5(String filePath) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
1010
        return getFileMD5(getFileByPath(filePath));
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
1011
    }
1012

                  
1017
     * @return 文件的MD5校验码
1018
     */
1019
    public static String getFileMD5(File file) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
1020
        return EncryptUtils.encryptMD5File2String(file);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
1021
    }
1022

                  
1026
     * @param closeables closeable
1027
     */
1028
    public static void closeIO(Closeable... closeables) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Do not use varargs.     NEW     squid:S923  
Functions should not be defined with a variable number of arguments
1029
        if (closeables == null) return;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
1030
        try {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
1031
            for (Closeable closeable : closeables) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
1032
                if (closeable != null) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Make this line start at column 9.     NEW     squid:IndentationCheck  
Source code should be indented consistently
1033
                    closeable.close();
Make this line start at column 11.     NEW     squid:IndentationCheck  
Source code should be indented consistently
1034
                }
1035
            }
1036
        } catch (IOException e) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "catch" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
Either log or rethrow this exception.     NEW     squid:S1166  
Exception handlers should preserve the original exceptions
1037
            e.printStackTrace();
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Use a logger to log this exception.     NEW     squid:S1148  
Throwable.printStackTrace(...) should not be called
1038
        }
1039
    }
1045
     * @return filePath最长目录
1046
     */
1047
    public static String getDirName(File file) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
1048
        if (file == null) return null;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
1049
        return getDirName(file.getPath());
1050
    }
1056
     * @return filePath最长目录
1057
     */
1058
    public static String getDirName(String filePath) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
1059
        if (StringUtils.isSpace(filePath)) return filePath;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
1060
        int lastSep = filePath.lastIndexOf(File.separator);
1061
        return lastSep == -1 ? "" : filePath.substring(0, lastSep + 1);
Convert this usage of the ternary operator to an "if"/"else" structure.     NEW     squid:S1774  
The ternary operator should not be used
1062
    }
1063

                  
1068
     * @return 文件名
1069
     */
1070
    public static String getFileName(File file) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
1071
        if (file == null) return null;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
1072
        return getFileName(file.getPath());
1073
    }
1079
     * @return 文件名
1080
     */
1081
    public static String getFileName(String filePath) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
1082
        if (StringUtils.isSpace(filePath)) return filePath;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
1083
        int lastSep = filePath.lastIndexOf(File.separator);
1084
        return lastSep == -1 ? filePath : filePath.substring(lastSep + 1);
Convert this usage of the ternary operator to an "if"/"else" structure.     NEW     squid:S1774  
The ternary operator should not be used
1085
    }
1086

                  
1091
     * @return 不带拓展名的文件名
1092
     */
1093
    public static String getFileNameNoExtension(File file) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
1094
        if (file == null) return null;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
1095
        return getFileNameNoExtension(file.getPath());
1096
    }
1102
     * @return 不带拓展名的文件名
1103
     */
1104
    public static String getFileNameNoExtension(String filePath) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Reduce the number of returns of this method 4, down to the maximum allowed 3.     NEW     squid:S1142  
Methods should not have too many return statements
1105
        if (StringUtils.isSpace(filePath)) return filePath;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
1106
        int lastPoi = filePath.lastIndexOf('.');
1107
        int lastSep = filePath.lastIndexOf(File.separator);
1108
        if (lastSep == -1) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
1109
            return (lastPoi == -1 ? filePath : filePath.substring(0, lastPoi));
Remove those useless parentheses.     NEW     squid:UselessParenthesesCheck  
Useless parentheses around expressions should be removed to prevent any misunderstanding
Convert this usage of the ternary operator to an "if"/"else" structure.     NEW     squid:S1774  
The ternary operator should not be used
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
1110
        }
1111
        if (lastPoi == -1 || lastSep > lastPoi) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
1112
            return filePath.substring(lastSep + 1);
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
1113
        }
1114
        return filePath.substring(lastSep + 1, lastPoi);
1121
     * @return 文件拓展名
1122
     */
1123
    public static String getFileExtension(File file) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
1124
        if (file == null) return null;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
1125
        return getFileExtension(file.getPath());
1126
    }
1132
     * @return 文件拓展名
1133
     */
1134
    public static String getFileExtension(String filePath) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
1135
        if (StringUtils.isSpace(filePath)) return filePath;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
1136
        int lastPoi = filePath.lastIndexOf('.');
1137
        int lastSep = filePath.lastIndexOf(File.separator);
1138
        if (lastPoi == -1 || lastSep >= lastPoi) return "";
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
1139
        return filePath.substring(lastPoi + 1);
1140
    }
536
New issues
Add or update the header of this file.     NEW     squid:S1451
Copyright and license headers should be defined
This file has 1,484 lines, which is greater than 1,000 authorized. Split it into smaller files.     NEW     squid:S00104
Files should not have too many lines
Add a new line at the end of this file.     NEW     squid:S00113
Files should contain an empty new line at the end
1
package com.blankj.utilcode.utils;
2

                  
49
 * </pre>
50
 */
51
public class ImageUtils {
Make this class "final" or add a public constructor.     NEW     squid:S2974  
Classes without "public" constructors should be "final"
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Split this class into smaller and more specialized ones to reduce its dependencies on other classes from 27 to the maximum authorized 20 or less.     NEW     squid:S1200  
Classes should not be coupled to too many other classes (Single Responsibility Principle)
class "ImageUtils" has 79 methods, which is greater than the 35 authorized. Split it into smaller classes.     NEW     squid:S1448  
Classes should not have too many methods
The Cyclomatic Complexity of this class is 283 which is greater than 200 authorized.     NEW     squid:ClassCyclomaticComplexity  
Classes should not be too complex
52

                  
53
    private ImageUtils() {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Make this line start at column 3.     NEW     squid:IndentationCheck  
Source code should be indented consistently
54
        throw new UnsupportedOperationException("u can't instantiate me...");
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
55
    }
56

                  
62
     * @return 字节数组
63
     */
64
    public static byte[] bitmap2Bytes(Bitmap bitmap, CompressFormat format) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
65
        return ConvertUtils.bitmap2Bytes(bitmap, format);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
66
    }
67

                  
72
     * @return bitmap
73
     */
74
    public static Bitmap bytes2Bitmap(byte[] bytes) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
75
        return ConvertUtils.bytes2Bitmap(bytes);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
76
    }
77

                  
82
     * @return bitmap
83
     */
84
    public static Bitmap drawable2Bitmap(Drawable drawable) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
85
        return ConvertUtils.drawable2Bitmap(drawable);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
86
    }
87

                  
93
     * @return drawable
94
     */
95
    public static Drawable bitmap2Drawable(Resources res, Bitmap bitmap) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
96
        return ConvertUtils.bitmap2Drawable(res, bitmap);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
97
    }
98

                  
104
     * @return 字节数组
105
     */
106
    public static byte[] drawable2Bytes(Drawable drawable, CompressFormat format) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
107
        return ConvertUtils.drawable2Bytes(drawable, format);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
108
    }
109

                  
115
     * @return drawable
116
     */
117
    public static Drawable bytes2Drawable(Resources res, byte[] bytes) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
118
        return ConvertUtils.bytes2Drawable(res, bytes);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
119
    }
120

                  
125
     * @return bitmap
126
     */
127
    public static Bitmap view2Bitmap(View view) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
128
        return ConvertUtils.view2Bitmap(view);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
129
    }
130

                  
137
     * @return 采样大小
138
     */
139
    private static int calculateInSampleSize(BitmapFactory.Options options, int maxWidth, int maxHeight) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
140
        if (maxWidth == 0 || maxHeight == 0) return 1;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
141
        int height = options.outHeight;
142
        int width = options.outWidth;
143
        int inSampleSize = 1;
144
        while ((height >>= 1) >= maxHeight && (width >>= 1) >= maxWidth) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
145
            inSampleSize <<= 1;
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
146
        }
147
        return inSampleSize;
154
     * @return bitmap
155
     */
156
    public static Bitmap getBitmap(File file) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
157
        if (file == null) return null;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
158
        InputStream is = null;
159
        try {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Change this "try" to a try-with-resources. (sonar.java.source not set. Assuming 7 or greater.)     NEW     squid:S2093  
Try-with-resources should be used
160
            is = new BufferedInputStream(new FileInputStream(file));
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Close this "FileInputStream".     NEW     squid:S2095  
Resources should be closed
161
            return BitmapFactory.decodeStream(is);
162
        } catch (FileNotFoundException e) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "catch" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
Either log or rethrow this exception.     NEW     squid:S1166  
Exception handlers should preserve the original exceptions
163
            e.printStackTrace();
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Use a logger to log this exception.     NEW     squid:S1148  
Throwable.printStackTrace(...) should not be called
164
            return null;
165
        } finally {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "finally" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
166
            FileUtils.closeIO(is);
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
167
        }
168
    }
176
     * @return bitmap
177
     */
178
    public static Bitmap getBitmap(File file, int maxWidth, int maxHeight) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
179
        if (file == null) return null;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
180
        InputStream is = null;
181
        try {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Change this "try" to a try-with-resources. (sonar.java.source not set. Assuming 7 or greater.)     NEW     squid:S2093  
Try-with-resources should be used
182
            BitmapFactory.Options options = new BitmapFactory.Options();
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
183
            options.inJustDecodeBounds = true;
184
            is = new BufferedInputStream(new FileInputStream(file));
Close this "FileInputStream".     NEW     squid:S2095  
Resources should be closed
185
            BitmapFactory.decodeStream(is, null, options);
186
            options.inSampleSize = calculateInSampleSize(options, maxWidth, maxHeight);
187
            options.inJustDecodeBounds = false;
188
            return BitmapFactory.decodeStream(is, null, options);
189
        } catch (FileNotFoundException e) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "catch" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
Either log or rethrow this exception.     NEW     squid:S1166  
Exception handlers should preserve the original exceptions
190
            e.printStackTrace();
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Use a logger to log this exception.     NEW     squid:S1148  
Throwable.printStackTrace(...) should not be called
191
            return null;
192
        } finally {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "finally" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
193
            FileUtils.closeIO(is);
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
194
        }
195
    }
201
     * @return bitmap
202
     */
203
    public static Bitmap getBitmap(String filePath) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
204
        if (StringUtils.isSpace(filePath)) return null;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
205
        return BitmapFactory.decodeFile(filePath);
206
    }
214
     * @return bitmap
215
     */
216
    public static Bitmap getBitmap(String filePath, int maxWidth, int maxHeight) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
217
        if (StringUtils.isSpace(filePath)) return null;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
218
        BitmapFactory.Options options = new BitmapFactory.Options();
219
        options.inJustDecodeBounds = true;
230
     * @return bitmap
231
     */
232
    public Bitmap getBitmap(InputStream is) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
233
        if (is == null) return null;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
234
        return BitmapFactory.decodeStream(is);
235
    }
243
     * @return bitmap
244
     */
245
    public static Bitmap getBitmap(InputStream is, int maxWidth, int maxHeight) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
246
        if (is == null) return null;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
247
        BitmapFactory.Options options = new BitmapFactory.Options();
248
        options.inJustDecodeBounds = true;
260
     * @return bitmap
261
     */
262
    public Bitmap getBitmap(byte[] data, int offset) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
263
        if (data.length == 0) return null;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
264
        return BitmapFactory.decodeByteArray(data, offset, data.length);
265
    }
274
     * @return bitmap
275
     */
276
    public static Bitmap getBitmap(byte[] data, int offset, int maxWidth, int maxHeight) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
277
        if (data.length == 0) return null;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
278
        BitmapFactory.Options options = new BitmapFactory.Options();
279
        options.inJustDecodeBounds = true;
291
     * @return bitmap
292
     */
293
    public static Bitmap getBitmap(Resources res, int id) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
294
        if (res == null) return null;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
295
        return BitmapFactory.decodeResource(res, id);
296
    }
305
     * @return bitmap
306
     */
307
    public static Bitmap getBitmap(Resources res, int id, int maxWidth, int maxHeight) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
308
        if (res == null) return null;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
309
        BitmapFactory.Options options = new BitmapFactory.Options();
310
        options.inJustDecodeBounds = true;
321
     * @return bitmap
322
     */
323
    public static Bitmap getBitmap(FileDescriptor fd) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
324
        if (fd == null) return null;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
325
        return BitmapFactory.decodeFileDescriptor(fd);
326
    }
334
     * @return bitmap
335
     */
336
    public static Bitmap getBitmap(FileDescriptor fd, int maxWidth, int maxHeight) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
337
        if (fd == null) return null;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
338
        BitmapFactory.Options options = new BitmapFactory.Options();
339
        options.inJustDecodeBounds = true;
352
     * @return 缩放后的图片
353
     */
354
    public static Bitmap scale(Bitmap src, int newWidth, int newHeight) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
355
        return scale(src, newWidth, newHeight, false);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
356
    }
357

                  
365
     * @return 缩放后的图片
366
     */
367
    public static Bitmap scale(Bitmap src, int newWidth, int newHeight, boolean recycle) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
368
        if (isEmptyBitmap(src)) return null;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
369
        Bitmap ret = Bitmap.createScaledBitmap(src, newWidth, newHeight, true);
370
        if (recycle && !src.isRecycled()) src.recycle();
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
371
        return ret;
372
    }
380
     * @return 缩放后的图片
381
     */
382
    public static Bitmap scale(Bitmap src, float scaleWidth, float scaleHeight) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
383
        return scale(src, scaleWidth, scaleHeight, false);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
384
    }
385

                  
393
     * @return 缩放后的图片
394
     */
395
    public static Bitmap scale(Bitmap src, float scaleWidth, float scaleHeight, boolean recycle) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
396
        if (isEmptyBitmap(src)) return null;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
397
        Matrix matrix = new Matrix();
398
        matrix.setScale(scaleWidth, scaleHeight);
399
        Bitmap ret = Bitmap.createBitmap(src, 0, 0, src.getWidth(), src.getHeight(), matrix, true);
400
        if (recycle && !src.isRecycled()) src.recycle();
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
401
        return ret;
402
    }
412
     * @return 裁剪后的图片
413
     */
414
    public static Bitmap clip(Bitmap src, int x, int y, int width, int height) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
415
        return clip(src, x, y, width, height, false);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
416
    }
417

                  
427
     * @return 裁剪后的图片
428
     */
429
    public static Bitmap clip(Bitmap src, int x, int y, int width, int height, boolean recycle) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
430
        if (isEmptyBitmap(src)) return null;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
431
        Bitmap ret = Bitmap.createBitmap(src, x, y, width, height);
432
        if (recycle && !src.isRecycled()) src.recycle();
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
433
        return ret;
434
    }
442
     * @return 倾斜后的图片
443
     */
444
    public static Bitmap skew(Bitmap src, float kx, float ky) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
445
        return skew(src, kx, ky, 0, 0, false);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
446
    }
447

                  
455
     * @return 倾斜后的图片
456
     */
457
    public static Bitmap skew(Bitmap src, float kx, float ky, boolean recycle) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
458
        return skew(src, kx, ky, 0, 0, recycle);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
459
    }
460

                  
469
     * @return 倾斜后的图片
470
     */
471
    public static Bitmap skew(Bitmap src, float kx, float ky, float px, float py) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Remove this unused method parameter "px".     NEW     squid:S1172  
Unused method parameters should be removed
472
        return skew(src, kx, ky, 0, 0, false);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
473
    }
474

                  
484
     * @return 倾斜后的图片
485
     */
486
    public static Bitmap skew(Bitmap src, float kx, float ky, float px, float py, boolean recycle) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
487
        if (isEmptyBitmap(src)) return null;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
488
        Matrix matrix = new Matrix();
489
        matrix.setSkew(kx, ky, px, py);
490
        Bitmap ret = Bitmap.createBitmap(src, 0, 0, src.getWidth(), src.getHeight(), matrix, true);
491
        if (recycle && !src.isRecycled()) src.recycle();
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
492
        return ret;
493
    }
502
     * @return 旋转后的图片
503
     */
504
    public static Bitmap rotate(Bitmap src, int degrees, float px, float py) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
505
        return rotate(src, degrees, px, py, false);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
506
    }
507

                  
516
     * @return 旋转后的图片
517
     */
518
    public static Bitmap rotate(Bitmap src, int degrees, float px, float py, boolean recycle) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
519
        if (isEmptyBitmap(src)) return null;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
520
        if (degrees == 0) return src;
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
521
        Matrix matrix = new Matrix();
522
        matrix.setRotate(degrees, px, py);
523
        Bitmap ret = Bitmap.createBitmap(src, 0, 0, src.getWidth(), src.getHeight(), matrix, true);
524
        if (recycle && !src.isRecycled()) src.recycle();
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
525
        return ret;
526
    }
532
     * @return 旋转角度
533
     */
534
    public static int getRotateDegree(String filePath) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
535
        int degree = 0;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
536
        try {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
537
            ExifInterface exifInterface = new ExifInterface(filePath);
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
538
            int orientation = exifInterface.getAttributeInt(
539
                    ExifInterface.TAG_ORIENTATION,
540
                    ExifInterface.ORIENTATION_NORMAL);
541
            switch (orientation) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
542
                default:
Move this default to the end of the switch.     NEW     squid:SwitchLastCaseIsDefaultCheck  
"switch" statements should end with "default" clauses
543
                case ExifInterface.ORIENTATION_ROTATE_90:
544
                    degree = 90;
Make this line start at column 11.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Assign this magic number 90 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
545
                    break;
546
                case ExifInterface.ORIENTATION_ROTATE_180:
547
                    degree = 180;
Make this line start at column 11.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Assign this magic number 180 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
548
                    break;
549
                case ExifInterface.ORIENTATION_ROTATE_270:
550
                    degree = 270;
Make this line start at column 11.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Assign this magic number 270 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
551
                    break;
552
            }
553
        } catch (IOException e) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "catch" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
Either log or rethrow this exception.     NEW     squid:S1166  
Exception handlers should preserve the original exceptions
554
            e.printStackTrace();
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Use a logger to log this exception.     NEW     squid:S1148  
Throwable.printStackTrace(...) should not be called
555
        }
556
        return degree;
563
     * @return 圆形图片
564
     */
565
    public static Bitmap toRound(Bitmap src) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
566
        return toRound(src, false);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
567
    }
568

                  
574
     * @return 圆形图片
575
     */
576
    public static Bitmap toRound(Bitmap src, boolean recycle) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
577
        if (isEmptyBitmap(src)) return null;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
578
        int width = src.getWidth();
579
        int height = src.getHeight();
588
        paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
589
        canvas.drawBitmap(src, rect, rect, paint);
590
        if (recycle && !src.isRecycled()) src.recycle();
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
591
        return ret;
592
    }
599
     * @return 圆角图片
600
     */
601
    public static Bitmap toRoundCorner(Bitmap src, float radius) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
602
        return toRoundCorner(src, radius, false);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
603
    }
604

                  
611
     * @return 圆角图片
612
     */
613
    public static Bitmap toRoundCorner(Bitmap src, float radius, boolean recycle) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
614
        if (null == src) return null;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
615
        int width = src.getWidth();
616
        int height = src.getHeight();
624
        paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
625
        canvas.drawBitmap(src, rect, rect, paint);
626
        if (recycle && !src.isRecycled()) src.recycle();
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
627
        return ret;
628
    }
638
     * @return 模糊后的图片
639
     */
640
    public static Bitmap fastBlur(Context context, Bitmap src, float scale, float radius) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
641
        return fastBlur(context, src, scale, radius, false);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
642
    }
643

                  
653
     * @return 模糊后的图片
654
     */
655
    public static Bitmap fastBlur(Context context, Bitmap src, float scale, float radius, boolean recycle) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Reduce the number of returns of this method 4, down to the maximum allowed 3.     NEW     squid:S1142  
Methods should not have too many return statements
The Cyclomatic Complexity of this method "fastBlur" is 13 which is greater than 10 authorized.     NEW     squid:MethodCyclomaticComplexity  
Methods should not be too complex
656
        if (isEmptyBitmap(src)) return null;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
657
        int width = src.getWidth();
658
        int height = src.getHeight();
659
        int scaleWidth = (int) (width * scale + 0.5f);
Use a "double" or "BigDecimal" instead.     NEW     squid:S2164  
Math should not be performed on floats
Upper-case this literal "f" suffix.     NEW     squid:S818  
Literal suffixes should be upper case
Assign this magic number 0.5f to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
660
        int scaleHeight = (int) (height * scale + 0.5f);
Use a "double" or "BigDecimal" instead.     NEW     squid:S2164  
Math should not be performed on floats
Upper-case this literal "f" suffix.     NEW     squid:S818  
Literal suffixes should be upper case
Assign this magic number 0.5f to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
661
        if (scaleWidth == 0 || scaleHeight == 0) return null;
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
662
        Bitmap scaleBitmap = Bitmap.createScaledBitmap(src, scaleWidth, scaleHeight, true);
663
        Paint paint = new Paint(Paint.FILTER_BITMAP_FLAG | Paint.ANTI_ALIAS_FLAG);
668
        canvas.scale(scale, scale);
669
        canvas.drawBitmap(scaleBitmap, 0, 0, paint);
670
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
671
            scaleBitmap = renderScriptBlur(context, scaleBitmap, radius);
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
672
        } else {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "else" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
673
            scaleBitmap = stackBlur(scaleBitmap, (int) radius, recycle);
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
674
        }
675
        if (scale == 1) return scaleBitmap;
Equality tests should not be made with floating point values.     NEW     squid:S1244  
Floating point numbers should not be tested for equality
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
676
        Bitmap ret = Bitmap.createScaledBitmap(scaleBitmap, width, height, true);
677
        if (scaleBitmap != null && !scaleBitmap.isRecycled()) scaleBitmap.recycle();
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
678
        if (recycle && !src.isRecycled()) src.recycle();
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
679
        return ret;
680
    }
690
     */
691
    @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
692
    public static Bitmap renderScriptBlur(Context context, Bitmap src, float radius) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
693
        if (isEmptyBitmap(src)) return null;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
694
        RenderScript rs = null;
695
        try {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
696
            rs = RenderScript.create(context);
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
697
            rs.setMessageHandler(new RenderScript.RSMessageHandler());
698
            Allocation input = Allocation.createFromBitmap(rs, src, Allocation.MipmapControl.MIPMAP_NONE, Allocation
700
            Allocation output = Allocation.createTyped(rs, input.getType());
701
            ScriptIntrinsicBlur blurScript = ScriptIntrinsicBlur.create(rs, Element.U8_4(rs));
702
            if (radius > 25) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Assign this magic number 25 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
703
                radius = 25.0f;
Make this line start at column 9.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Upper-case this literal "f" suffix.     NEW     squid:S818  
Literal suffixes should be upper case
Assign this magic number 25.0f to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Introduce a new variable instead of reusing the parameter "radius".     NEW     squid:S1226  
Method parameters, caught exceptions and foreach variables should not be reassigned
704
            } else if (radius <= 0) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "else" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
705
                radius = 1.0f;
Make this line start at column 9.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Upper-case this literal "f" suffix.     NEW     squid:S818  
Literal suffixes should be upper case
Introduce a new variable instead of reusing the parameter "radius".     NEW     squid:S1226  
Method parameters, caught exceptions and foreach variables should not be reassigned
706
            }
707
            blurScript.setInput(input);
709
            blurScript.forEach(output);
710
            output.copyTo(src);
711
        } finally {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "finally" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
712
            if (rs != null) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
713
                rs.destroy();
Make this line start at column 9.     NEW     squid:IndentationCheck  
Source code should be indented consistently
714
            }
715
        }
725
     * @return stack模糊后的图片
726
     */
727
    public static Bitmap stackBlur(Bitmap src, int radius, boolean recycle) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Provide multiple methods instead of using "recycle" to determine which action to take.     NEW     squid:S2301  
Public methods should not contain selector arguments
This method has 203 lines, which is greater than the 100 lines authorized. Split it into smaller methods.     NEW     squid:S138  
Methods should not have too many lines
The Cyclomatic Complexity of this method "stackBlur" is 16 which is greater than 10 authorized.     NEW     squid:MethodCyclomaticComplexity  
Methods should not be too complex
728
        Bitmap ret;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
729
        if (recycle) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
730
            ret = src;
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
731
        } else {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "else" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
732
            ret = src.copy(src.getConfig(), true);
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
733
        }
734

                  
735
        if (radius < 1) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
736
            return null;
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
737
        }
738

                  
748
        int div = radius + radius + 1;
749

                  
750
        int r[] = new int[wh];
Move the array designator from the variable to the type.     NEW     squid:S1197  
Array designators "[]" should be on the type, not the variable
751
        int g[] = new int[wh];
Move the array designator from the variable to the type.     NEW     squid:S1197  
Array designators "[]" should be on the type, not the variable
752
        int b[] = new int[wh];
Move the array designator from the variable to the type.     NEW     squid:S1197  
Array designators "[]" should be on the type, not the variable
753
        int rsum, gsum, bsum, x, y, i, p, yp, yi, yw;
Declare "gsum" on a separate line.     NEW     squid:S1659  
Multiple variables should not be declared on the same line
Declare "bsum" on a separate line.     NEW     squid:S1659  
Multiple variables should not be declared on the same line
Declare "x" on a separate line.     NEW     squid:S1659  
Multiple variables should not be declared on the same line
Declare "y" on a separate line.     NEW     squid:S1659  
Multiple variables should not be declared on the same line
Declare "i" on a separate line.     NEW     squid:S1659  
Multiple variables should not be declared on the same line
Declare "p" on a separate line.     NEW     squid:S1659  
Multiple variables should not be declared on the same line
Declare "yp" on a separate line.     NEW     squid:S1659  
Multiple variables should not be declared on the same line
Declare "yi" on a separate line.     NEW     squid:S1659  
Multiple variables should not be declared on the same line
Declare "yw" on a separate line.     NEW     squid:S1659  
Multiple variables should not be declared on the same line
754
        int vmin[] = new int[Math.max(w, h)];
Move the array designator from the variable to the type.     NEW     squid:S1197  
Array designators "[]" should be on the type, not the variable
755

                  
756
        int divsum = (div + 1) >> 1;
757
        divsum *= divsum;
758
        int dv[] = new int[256 * divsum];
Move the array designator from the variable to the type.     NEW     squid:S1197  
Array designators "[]" should be on the type, not the variable
Assign this magic number 256 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
759
        for (i = 0; i < 256 * divsum; i++) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Assign this magic number 256 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
760
            dv[i] = (i / divsum);
Remove those useless parentheses.     NEW     squid:UselessParenthesesCheck  
Useless parentheses around expressions should be removed to prevent any misunderstanding
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
761
        }
762

                  
763
        yw = yi = 0;
764

                  
765
        int[][] stack = new int[div][3];
Assign this magic number 3 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
766
        int stackpointer;
767
        int stackstart;
769
        int rbs;
770
        int r1 = radius + 1;
771
        int routsum, goutsum, boutsum;
Declare "goutsum" on a separate line.     NEW     squid:S1659  
Multiple variables should not be declared on the same line
Declare "boutsum" on a separate line.     NEW     squid:S1659  
Multiple variables should not be declared on the same line
772
        int rinsum, ginsum, binsum;
Declare "ginsum" on a separate line.     NEW     squid:S1659  
Multiple variables should not be declared on the same line
Declare "binsum" on a separate line.     NEW     squid:S1659  
Multiple variables should not be declared on the same line
773

                  
774
        for (y = 0; y < h; y++) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
775
            rinsum = ginsum = binsum = routsum = goutsum = boutsum = rsum = gsum = bsum = 0;
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
776
            for (i = -radius; i <= radius; i++) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
777
                p = pix[yi + Math.min(wm, Math.max(i, 0))];
Make this line start at column 9.     NEW     squid:IndentationCheck  
Source code should be indented consistently
778
                sir = stack[i + radius];
779
                sir[0] = (p & 0xff0000) >> 16;
Assign this magic number 16 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
780
                sir[1] = (p & 0x00ff00) >> 8;
Assign this magic number 8 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
781
                sir[2] = (p & 0x0000ff);
Remove those useless parentheses.     NEW     squid:UselessParenthesesCheck  
Useless parentheses around expressions should be removed to prevent any misunderstanding
Assign this magic number 2 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
782
                rbs = r1 - Math.abs(i);
783
                rsum += sir[0] * rbs;
784
                gsum += sir[1] * rbs;
785
                bsum += sir[2] * rbs;
Assign this magic number 2 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
786
                if (i > 0) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
787
                    rinsum += sir[0];
Make this line start at column 11.     NEW     squid:IndentationCheck  
Source code should be indented consistently
788
                    ginsum += sir[1];
789
                    binsum += sir[2];
Assign this magic number 2 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
790
                } else {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "else" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
791
                    routsum += sir[0];
Make this line start at column 11.     NEW     squid:IndentationCheck  
Source code should be indented consistently
792
                    goutsum += sir[1];
793
                    boutsum += sir[2];
Assign this magic number 2 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
794
                }
795
            }
796
            stackpointer = radius;
797

                  
798
            for (x = 0; x < w; x++) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
799

                  
800
                r[yi] = dv[rsum];
Make this line start at column 9.     NEW     squid:IndentationCheck  
Source code should be indented consistently
801
                g[yi] = dv[gsum];
802
                b[yi] = dv[bsum];
811
                routsum -= sir[0];
812
                goutsum -= sir[1];
813
                boutsum -= sir[2];
Assign this magic number 2 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
814

                  
815
                if (y == 0) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
816
                    vmin[x] = Math.min(x + radius + 1, wm);
Make this line start at column 11.     NEW     squid:IndentationCheck  
Source code should be indented consistently
817
                }
818
                p = pix[yw + vmin[x]];
819

                  
820
                sir[0] = (p & 0xff0000) >> 16;
Assign this magic number 16 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
821
                sir[1] = (p & 0x00ff00) >> 8;
Assign this magic number 8 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
822
                sir[2] = (p & 0x0000ff);
Remove those useless parentheses.     NEW     squid:UselessParenthesesCheck  
Useless parentheses around expressions should be removed to prevent any misunderstanding
Assign this magic number 2 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
823

                  
824
                rinsum += sir[0];
825
                ginsum += sir[1];
826
                binsum += sir[2];
Assign this magic number 2 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
827

                  
828
                rsum += rinsum;
835
                routsum += sir[0];
836
                goutsum += sir[1];
837
                boutsum += sir[2];
Assign this magic number 2 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
838

                  
839
                rinsum -= sir[0];
840
                ginsum -= sir[1];
841
                binsum -= sir[2];
Assign this magic number 2 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
842

                  
843
                yi++;
845
            yw += w;
846
        }
847
        for (x = 0; x < w; x++) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
848
            rinsum = ginsum = binsum = routsum = goutsum = boutsum = rsum = gsum = bsum = 0;
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
849
            yp = -radius * w;
850
            for (i = -radius; i <= radius; i++) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
851
                yi = Math.max(0, yp) + x;
Make this line start at column 9.     NEW     squid:IndentationCheck  
Source code should be indented consistently
852

                  
853
                sir = stack[i + radius];
855
                sir[0] = r[yi];
856
                sir[1] = g[yi];
857
                sir[2] = b[yi];
Assign this magic number 2 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
858

                  
859
                rbs = r1 - Math.abs(i);
863
                bsum += b[yi] * rbs;
864

                  
865
                if (i > 0) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
866
                    rinsum += sir[0];
Make this line start at column 11.     NEW     squid:IndentationCheck  
Source code should be indented consistently
867
                    ginsum += sir[1];
868
                    binsum += sir[2];
Assign this magic number 2 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
869
                } else {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "else" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
870
                    routsum += sir[0];
Make this line start at column 11.     NEW     squid:IndentationCheck  
Source code should be indented consistently
871
                    goutsum += sir[1];
872
                    boutsum += sir[2];
Assign this magic number 2 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
873
                }
874

                  
875
                if (i < hm) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
876
                    yp += w;
Make this line start at column 11.     NEW     squid:IndentationCheck  
Source code should be indented consistently
877
                }
878
            }
879
            yi = x;
880
            stackpointer = radius;
881
            for (y = 0; y < h; y++) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
882
                // Preserve alpha channel: ( 0xff000000 & pix[yi] )
883
                pix[yi] = (0xff000000 & pix[yi]) | (dv[rsum] << 16) | (dv[gsum] << 8) | dv[bsum];
Make this line start at column 9.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Assign this magic number 16 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 8 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
884

                  
885
                rsum -= routsum;
892
                routsum -= sir[0];
893
                goutsum -= sir[1];
894
                boutsum -= sir[2];
Assign this magic number 2 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
895

                  
896
                if (x == 0) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
897
                    vmin[y] = Math.min(y + r1, hm) * w;
Make this line start at column 11.     NEW     squid:IndentationCheck  
Source code should be indented consistently
898
                }
899
                p = x + vmin[y];
901
                sir[0] = r[p];
902
                sir[1] = g[p];
903
                sir[2] = b[p];
Assign this magic number 2 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
904

                  
905
                rinsum += sir[0];
906
                ginsum += sir[1];
907
                binsum += sir[2];
Assign this magic number 2 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
908

                  
909
                rsum += rinsum;
916
                routsum += sir[0];
917
                goutsum += sir[1];
918
                boutsum += sir[2];
Assign this magic number 2 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
919

                  
920
                rinsum -= sir[0];
921
                ginsum -= sir[1];
922
                binsum -= sir[2];
Assign this magic number 2 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
923

                  
924
                yi += w;
937
     * @return 带颜色边框图
938
     */
939
    public static Bitmap addFrame(Bitmap src, int borderWidth, int color) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
940
        return addFrame(src, borderWidth, color, false);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
941
    }
942

                  
950
     * @return 带颜色边框图
951
     */
952
    public static Bitmap addFrame(Bitmap src, int borderWidth, int color, boolean recycle) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
953
        if (isEmptyBitmap(src)) return null;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
954
        int doubleBorder = borderWidth << 1;
955
        int newWidth = src.getWidth() + doubleBorder;
965
        canvas.drawRect(rect, paint);
966
        canvas.drawBitmap(src, borderWidth, borderWidth, null);
967
        if (recycle && !src.isRecycled()) src.recycle();
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
968
        return ret;
969
    }
976
     * @return 带倒影图片
977
     */
978
    public static Bitmap addReflection(Bitmap src, int reflectionHeight) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
979
        return addReflection(src, reflectionHeight, false);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
980
    }
981

                  
988
     * @return 带倒影图片
989
     */
990
    public static Bitmap addReflection(Bitmap src, int reflectionHeight, boolean recycle) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Reduce the number of returns of this method 4, down to the maximum allowed 3.     NEW     squid:S1142  
Methods should not have too many return statements
The Cyclomatic Complexity of this method "addReflection" is 11 which is greater than 10 authorized.     NEW     squid:MethodCyclomaticComplexity  
Methods should not be too complex
991
        if (isEmptyBitmap(src)) return null;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
992
        final int REFLECTION_GAP = 0;
Rename this local variable name to match the regular expression '^[a-z][a-zA-Z0-9]*$'.     NEW     squid:S00117  
Local variable and method parameter names should comply with a naming convention
Move the declaration of "REFLECTION_GAP" closer to the code that uses it.     NEW     squid:S1941  
Variables should not be declared before they are relevant
993
        int srcWidth = src.getWidth();
994
        int srcHeight = src.getHeight();
995
        if (0 == srcWidth || srcHeight == 0) return null;
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
996
        Matrix matrix = new Matrix();
997
        matrix.preScale(1, -1);
998
        Bitmap reflectionBitmap = Bitmap.createBitmap(src, 0, srcHeight - reflectionHeight,
999
                srcWidth, reflectionHeight, matrix, false);
1000
        if (null == reflectionBitmap) return null;
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
1001
        Bitmap ret = Bitmap.createBitmap(srcWidth, srcHeight + reflectionHeight, src.getConfig());
1002
        Canvas canvas = new Canvas(ret);
1010
        paint.setShader(shader);
1011
        paint.setXfermode(new PorterDuffXfermode(
1012
                android.graphics.PorterDuff.Mode.DST_IN));
Replace this fully qualified name with "android.graphics.PorterDuff"     NEW     squid:S1942  
Simple class names should be used
1013
        canvas.save();
1014
        canvas.drawRect(0, srcHeight, srcWidth,
1015
                ret.getHeight() + REFLECTION_GAP, paint);
1016
        canvas.restore();
1017
        if (!reflectionBitmap.isRecycled()) reflectionBitmap.recycle();
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
1018
        if (recycle && !src.isRecycled()) src.recycle();
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
1019
        return ret;
1020
    }
1032
     */
1033
    public static Bitmap addTextWatermark(Bitmap src, String content, int textSize, int color, float x,
1034
                                          float y) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
1035
        return addTextWatermark(src, content, textSize, color, x, y, false);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
1036
    }
1037

                  
1049
     */
1050
    public static Bitmap addTextWatermark(Bitmap src, String content, float textSize, int color, float x,
1051
                                          float y, boolean recycle) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
1052
        if (isEmptyBitmap(src) || content == null) return null;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
1053
        Bitmap ret = src.copy(src.getConfig(), true);
1054
        Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
1058
        Rect bounds = new Rect();
1059
        paint.getTextBounds(content, 0, content.length(), bounds);
1060
        canvas.drawText(content, x, y + textSize, paint);
Use a "double" or "BigDecimal" instead.     NEW     squid:S2164  
Math should not be performed on floats
1061
        if (recycle && !src.isRecycled()) src.recycle();
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
1062
        return ret;
1063
    }
1073
     * @return 带有图片水印的图片
1074
     */
1075
    public static Bitmap addImageWatermark(Bitmap src, Bitmap watermark, int x, int y, int alpha) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
1076
        return addImageWatermark(src, watermark, x, y, alpha, false);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
1077
    }
1078

                  
1088
     * @return 带有图片水印的图片
1089
     */
1090
    public static Bitmap addImageWatermark(Bitmap src, Bitmap watermark, int x, int y, int alpha, boolean recycle) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
1091
        if (isEmptyBitmap(src)) return null;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
1092
        Bitmap ret = src.copy(src.getConfig(), true);
1093
        if (!isEmptyBitmap(watermark)) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
1094
            Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
1095
            Canvas canvas = new Canvas(ret);
1096
            paint.setAlpha(alpha);
1097
            canvas.drawBitmap(watermark, x, y, paint);
1098
        }
1099
        if (recycle && !src.isRecycled()) src.recycle();
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
1100
        return ret;
1101
    }
1107
     * @return alpha位图
1108
     */
1109
    public static Bitmap toAlpha(Bitmap src) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
1110
        return toAlpha(src, false);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
1111
    }
1112

                  
1118
     * @return alpha位图
1119
     */
1120
    public static Bitmap toAlpha(Bitmap src, Boolean recycle) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
1121
        if (isEmptyBitmap(src)) return null;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
1122
        Bitmap ret = src.extractAlpha();
1123
        if (recycle && !src.isRecycled()) src.recycle();
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
1124
        return ret;
1125
    }
1131
     * @return 灰度图
1132
     */
1133
    public static Bitmap toGray(Bitmap src) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
1134
        return toGray(src, false);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
1135
    }
1136

                  
1142
     * @return 灰度图
1143
     */
1144
    public static Bitmap toGray(Bitmap src, boolean recycle) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
1145
        if (isEmptyBitmap(src)) return null;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
1146
        Bitmap grayBitmap = Bitmap.createBitmap(src.getWidth(),
1147
                src.getHeight(), Bitmap.Config.RGB_565);
1153
        paint.setColorFilter(colorMatrixColorFilter);
1154
        canvas.drawBitmap(src, 0, 0, paint);
1155
        if (recycle && !src.isRecycled()) src.recycle();
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
1156
        return grayBitmap;
1157
    }
1165
     * @return {@code true}: 成功<br>{@code false}: 失败
1166
     */
1167
    public static boolean save(Bitmap src, String filePath, CompressFormat format) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
1168
        return save(src, FileUtils.getFileByPath(filePath), format, false);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
1169
    }
1170

                  
1177
     * @return {@code true}: 成功<br>{@code false}: 失败
1178
     */
1179
    public static boolean save(Bitmap src, File file, CompressFormat format) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
1180
        return save(src, file, format, false);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
1181
    }
1182

                  
1190
     * @return {@code true}: 成功<br>{@code false}: 失败
1191
     */
1192
    public static boolean save(Bitmap src, String filePath, CompressFormat format, boolean recycle) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
1193
        return save(src, FileUtils.getFileByPath(filePath), format, recycle);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
1194
    }
1195

                  
1203
     * @return {@code true}: 成功<br>{@code false}: 失败
1204
     */
1205
    public static boolean save(Bitmap src, File file, CompressFormat format, boolean recycle) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
1206
        if (isEmptyBitmap(src) || !FileUtils.createOrExistsFile(file)) return false;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
1207
        System.out.println(src.getWidth() + ", " + src.getHeight());
Replace this usage of System.out or System.err by a logger.     NEW     squid:S106  
Standard outputs should not be used directly to log anything
1208
        OutputStream os = null;
1209
        boolean ret = false;
1210
        try {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Change this "try" to a try-with-resources. (sonar.java.source not set. Assuming 7 or greater.)     NEW     squid:S2093  
Try-with-resources should be used
1211
            os = new BufferedOutputStream(new FileOutputStream(file));
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Close this "FileOutputStream".     NEW     squid:S2095  
Resources should be closed
1212
            ret = src.compress(format, 100, os);
Assign this magic number 100 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
1213
            if (recycle && !src.isRecycled()) src.recycle();
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
1214
        } catch (IOException e) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "catch" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
Either log or rethrow this exception.     NEW     squid:S1166  
Exception handlers should preserve the original exceptions
1215
            e.printStackTrace();
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Use a logger to log this exception.     NEW     squid:S1148  
Throwable.printStackTrace(...) should not be called
1216
        } finally {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "finally" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
1217
            FileUtils.closeIO(os);
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
1218
        }
1219
        return ret;
1226
     * @return {@code true}: 是<br>{@code false}: 否
1227
     */
1228
    public static boolean isImage(File file) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
1229
        return file != null && isImage(file.getPath());
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
1230
    }
1231

                  
1236
     * @return {@code true}: 是<br>{@code false}: 否
1237
     */
1238
    public static boolean isImage(String filePath) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
1239
        String path = filePath.toUpperCase();
Define the locale to be used in this String operation.     NEW     squid:S1449  
Locale should be used in String operations
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
1240
        return path.endsWith(".PNG") || path.endsWith(".JPG")
Reduce the number of conditional operators (4) used in the expression (maximum allowed 3).     NEW     squid:S1067  
Expressions should not be too complex
1241
                || path.endsWith(".JPEG") || path.endsWith(".BMP")
1242
                || path.endsWith(".GIF");
1249
     * @return 图片类型
1250
     */
1251
    public static String getImageType(String filePath) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
1252
        return getImageType(FileUtils.getFileByPath(filePath));
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
1253
    }
1254

                  
1259
     * @return 图片类型
1260
     */
1261
    public static String getImageType(File file) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
1262
        if (file == null) return null;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
1263
        InputStream is = null;
1264
        try {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Change this "try" to a try-with-resources. (sonar.java.source not set. Assuming 7 or greater.)     NEW     squid:S2093  
Try-with-resources should be used
1265
            is = new FileInputStream(file);
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
1266
            return getImageType(is);
1267
        } catch (IOException e) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "catch" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
Either log or rethrow this exception.     NEW     squid:S1166  
Exception handlers should preserve the original exceptions
1268
            e.printStackTrace();
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Use a logger to log this exception.     NEW     squid:S1148  
Throwable.printStackTrace(...) should not be called
1269
            return null;
1270
        } finally {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "finally" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
1271
            FileUtils.closeIO(is);
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
1272
        }
1273
    }
1279
     * @return 图片类型
1280
     */
1281
    public static String getImageType(InputStream is) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
1282
        if (is == null) return null;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
1283
        try {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
1284
            byte[] bytes = new byte[8];
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Assign this magic number 8 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
1285
            return is.read(bytes, 0, 8) != -1 ? getImageType(bytes) : null;
Convert this usage of the ternary operator to an "if"/"else" structure.     NEW     squid:S1774  
The ternary operator should not be used
Assign this magic number 8 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
1286
        } catch (IOException e) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "catch" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
Either log or rethrow this exception.     NEW     squid:S1166  
Exception handlers should preserve the original exceptions
1287
            e.printStackTrace();
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Use a logger to log this exception.     NEW     squid:S1148  
Throwable.printStackTrace(...) should not be called
1288
            return null;
1289
        }
1296
     * @return 图片类型
1297
     */
1298
    public static String getImageType(byte[] bytes) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Reduce the number of returns of this method 5, down to the maximum allowed 3.     NEW     squid:S1142  
Methods should not have too many return statements
1299
        if (isJPEG(bytes)) return "JPEG";
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
1300
        if (isGIF(bytes)) return "GIF";
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
1301
        if (isPNG(bytes)) return "PNG";
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
1302
        if (isBMP(bytes)) return "BMP";
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
1303
        return null;
1304
    }
1305

                  
1306
    private static boolean isJPEG(byte[] b) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
1307
        return b.length >= 2
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Assign this magic number 2 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
1308
                && (b[0] == (byte) 0xFF) && (b[1] == (byte) 0xD8);
1309
    }
1310

                  
1311
    private static boolean isGIF(byte[] b) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
1312
        return b.length >= 6
Reduce the number of conditional operators (7) used in the expression (maximum allowed 3).     NEW     squid:S1067  
Expressions should not be too complex
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Assign this magic number 6 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
1313
                && b[0] == 'G' && b[1] == 'I'
1314
                && b[2] == 'F' && b[3] == '8'
Assign this magic number 2 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 3 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
1315
                && (b[4] == '7' || b[4] == '9') && b[5] == 'a';
Assign this magic number 4 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 4 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 5 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
1316
    }
1317

                  
1318
    private static boolean isPNG(byte[] b) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
1319
        return b.length >= 8
Reduce the number of conditional operators (8) used in the expression (maximum allowed 3).     NEW     squid:S1067  
Expressions should not be too complex
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Assign this magic number 8 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
1320
                && (b[0] == (byte) 137 && b[1] == (byte) 80
Assign this magic number 137 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 80 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
1321
                && b[2] == (byte) 78 && b[3] == (byte) 71
Assign this magic number 2 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 78 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 3 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 71 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
1322
                && b[4] == (byte) 13 && b[5] == (byte) 10
Assign this magic number 4 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 13 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 5 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 10 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
1323
                && b[6] == (byte) 26 && b[7] == (byte) 10);
Assign this magic number 6 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 26 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 7 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 10 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
1324
    }
1325

                  
1326
    private static boolean isBMP(byte[] b) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
1327
        return b.length >= 2
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Assign this magic number 2 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
1328
                && (b[0] == 0x42) && (b[1] == 0x4d);
1329
    }
1335
     * @return {@code true}: 是<br>{@code false}: 否
1336
     */
1337
    private static boolean isEmptyBitmap(Bitmap src) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
1338
        return src == null || src.getWidth() == 0 || src.getHeight() == 0;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
1339
    }
1340

                  
1349
     * @return 缩放压缩后的图片
1350
     */
1351
    public static Bitmap compressByScale(Bitmap src, int newWidth, int newHeight) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document the parameter(s): src, newWidth, newHeight     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
Document this method return value.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
1352
        return scale(src, newWidth, newHeight, false);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
1353
    }
1354

                  
1362
     * @return 缩放压缩后的图片
1363
     */
1364
    public static Bitmap compressByScale(Bitmap src, int newWidth, int newHeight, boolean recycle) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
1365
        return scale(src, newWidth, newHeight, recycle);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
1366
    }
1367

                  
1374
     * @return 缩放压缩后的图片
1375
     */
1376
    public static Bitmap compressByScale(Bitmap src, float scaleWidth, float scaleHeight) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
1377
        return scale(src, scaleWidth, scaleHeight, false);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
1378
    }
1379

                  
1387
     * @return 缩放压缩后的图片
1388
     */
1389
    public static Bitmap compressByScale(Bitmap src, float scaleWidth, float scaleHeight, boolean recycle) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
1390
        return scale(src, scaleWidth, scaleHeight, recycle);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
1391
    }
1392

                  
1398
     * @return 质量压缩后的图片
1399
     */
1400
    public static Bitmap compressByQuality(Bitmap src, int quality) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
1401
        return compressByQuality(src, quality, false);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
1402
    }
1403

                  
1410
     * @return 质量压缩后的图片
1411
     */
1412
    public static Bitmap compressByQuality(Bitmap src, int quality, boolean recycle) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
1413
        if (isEmptyBitmap(src) || quality < 0 || quality > 100) return null;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Assign this magic number 100 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
1414
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
1415
        src.compress(Bitmap.CompressFormat.JPEG, quality, baos);
1416
        byte[] bytes = baos.toByteArray();
1417
        if (recycle && !src.isRecycled()) src.recycle();
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
1418
        return BitmapFactory.decodeByteArray(bytes, 0, bytes.length);
1419
    }
1426
     * @return 质量压缩压缩过的图片
1427
     */
1428
    public static Bitmap compressByQuality(Bitmap src, long maxByteSize) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
1429
        return compressByQuality(src, maxByteSize, false);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
1430
    }
1431

                  
1438
     * @return 质量压缩压缩过的图片
1439
     */
1440
    public static Bitmap compressByQuality(Bitmap src, long maxByteSize, boolean recycle) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
1441
        if (isEmptyBitmap(src) || maxByteSize <= 0) return null;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
1442
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
1443
        int quality = 100;
Assign this magic number 100 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
1444
        src.compress(CompressFormat.JPEG, quality, baos);
1445
        while (baos.toByteArray().length > maxByteSize && quality >= 0) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
1446
            baos.reset();
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
1447
            src.compress(CompressFormat.JPEG, quality -= 5, baos);
Extract the assignment out of this expression.     NEW     squid:AssignmentInSubExpressionCheck  
Assignments should not be made from within sub-expressions
Assign this magic number 5 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
1448
        }
1449
        if (quality < 0) return null;
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
1450
        byte[] bytes = baos.toByteArray();
1451
        if (recycle && !src.isRecycled()) src.recycle();
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
1452
        return BitmapFactory.decodeByteArray(bytes, 0, bytes.length);
1453
    }
1460
     * @return 按采样率压缩后的图片
1461
     */
1462
    public static Bitmap compressBySampleSize(Bitmap src, int sampleSize) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
1463
        return compressBySampleSize(src, sampleSize, false);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
1464
    }
1465

                  
1472
     * @return 按采样率压缩后的图片
1473
     */
1474
    public static Bitmap compressBySampleSize(Bitmap src, int sampleSize, boolean recycle) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
1475
        if (isEmptyBitmap(src)) return null;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
1476
        BitmapFactory.Options options = new BitmapFactory.Options();
1477
        options.inSampleSize = sampleSize;
1478
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
1479
        src.compress(Bitmap.CompressFormat.JPEG, 100, baos);
Assign this magic number 100 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
1480
        byte[] bytes = baos.toByteArray();
1481
        if (recycle && !src.isRecycled()) src.recycle();
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
1482
        return BitmapFactory.decodeByteArray(bytes, 0, bytes.length, options);
1483
    }
47
New issues
Add or update the header of this file.     NEW     squid:S1451
Copyright and license headers should be defined
1
package com.blankj.utilcode.utils;
2

                  
21
 * </pre>
22
 */
23
public class IntentUtils {
Make this class "final" or add a public constructor.     NEW     squid:S2974  
Classes without "public" constructors should be "final"
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
24

                  
25
    private IntentUtils() {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Make this line start at column 3.     NEW     squid:IndentationCheck  
Source code should be indented consistently
26
        throw new UnsupportedOperationException("u can't fuck me...");
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
27
    }
28

                  
33
     * @return intent
34
     */
35
    public static Intent getInstallAppIntent(String filePath) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
36
        return getInstallAppIntent(FileUtils.getFileByPath(filePath));
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
37
    }
38

                  
43
     * @return intent
44
     */
45
    public static Intent getInstallAppIntent(File file) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
46
        if (file == null) return null;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
47
        Intent intent = new Intent(Intent.ACTION_VIEW);
48
        String type;
49
        if (Build.VERSION.SDK_INT < 23) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Assign this magic number 23 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
50
            type = "application/vnd.android.package-archive";
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
51
        } else {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "else" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
52
            type = MimeTypeMap.getSingleton().getMimeTypeFromExtension(FileUtils.getFileExtension(file));
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
53
        }
54
        intent.setDataAndType(Uri.fromFile(file), type);
62
     * @return intent
63
     */
64
    public static Intent getUninstallAppIntent(String packageName) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
65
        Intent intent = new Intent(Intent.ACTION_DELETE);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
66
        intent.setData(Uri.parse("package:" + packageName));
67
        return intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
75
     * @return intent
76
     */
77
    public static Intent getLaunchAppIntent(Context context, String packageName) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
78
        return context.getPackageManager().getLaunchIntentForPackage(packageName);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
79
    }
80

                  
85
     * @return intent
86
     */
87
    public static Intent getAppDetailsSettingsIntent(String packageName) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
88
        Intent intent = new Intent("android.settings.APPLICATION_DETAILS_SETTINGS");
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
89
        intent.setData(Uri.parse("package:" + packageName));
90
        return intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
97
     * @return intent
98
     */
99
    public static Intent getShareTextIntent(String content) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
100
        Intent intent = new Intent(Intent.ACTION_SEND);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
101
        intent.setType("text/plain");
102
        intent.putExtra(Intent.EXTRA_TEXT, content);
111
     * @return intent
112
     */
113
    public static Intent getShareImageIntent(String content, String imagePath) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
114
        return getShareImageIntent(content, FileUtils.getFileByPath(imagePath));
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
115
    }
116

                  
122
     * @return intent
123
     */
124
    public static Intent getShareImageIntent(String content, File image) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
125
        if (!FileUtils.isFileExists(image)) return null;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
126
        return getShareImageIntent(content, Uri.fromFile(image));
127
    }
134
     * @return intent
135
     */
136
    public static Intent getShareImageIntent(String content, Uri uri) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
137
        Intent intent = new Intent(Intent.ACTION_SEND);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
138
        intent.putExtra(Intent.EXTRA_TEXT, content);
139
        intent.putExtra(Intent.EXTRA_STREAM, uri);
149
     * @return intent
150
     */
151
    public static Intent getComponentIntent(String packageName, String className) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
152
        return getComponentIntent(packageName, className, null);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
153
    }
154

                  
160
     * @return intent
161
     */
162
    public static Intent getComponentIntent(String packageName, String className, Bundle bundle) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document the parameter(s): bundle     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
163
        Intent intent = new Intent(Intent.ACTION_VIEW);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
164
        if (bundle != null) intent.putExtras(bundle);
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
165
        ComponentName cn = new ComponentName(packageName, className);
166
        intent.setComponent(cn);
174
     * @return intent
175
     */
176
    public static Intent getShutdownIntnet() {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
177
        Intent intent = new Intent(Intent.ACTION_SHUTDOWN);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
178
        return intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
179
    }
185
     * @return 拍照的意图
186
     */
187
    public static Intent getCaptureIntent(Uri outUri) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
188
        Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
189
        intent.putExtra(MediaStore.EXTRA_OUTPUT, outUri);
190
        return intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_ACTIVITY_NEW_TASK);
196
     * @return
197
     *//*
198
    public static Intent getPickIntentWithGallery() {
This block of commented-out lines of code should be removed.     NEW     squid:CommentedOutCodeLine  
Sections of code should not be "commented out"
199
        Intent intent = new Intent(Intent.ACTION_PICK);
200
        return intent.setType("image*//*");
206
     * @return
207
     *//*
208
    public static Intent getPickIntentWithDocuments() {
This block of commented-out lines of code should be removed.     NEW     squid:CommentedOutCodeLine  
Sections of code should not be "commented out"
209
        Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
210
        return intent.setType("image*//*");
28
New issues
Add or update the header of this file.     NEW     squid:S1451
Copyright and license headers should be defined
Add a new line at the end of this file.     NEW     squid:S00113
Files should contain an empty new line at the end
1
package com.blankj.utilcode.utils;
2

                  
16
 * </pre>
17
 */
18
public class KeyboardUtils {
Make this class "final" or add a public constructor.     NEW     squid:S2974  
Classes without "public" constructors should be "final"
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
19

                  
20
    private KeyboardUtils() {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Make this line start at column 3.     NEW     squid:IndentationCheck  
Source code should be indented consistently
21
        throw new UnsupportedOperationException("u can't instantiate me...");
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
22
    }
23

                  
33
     * @param activity activity
34
     */
35
    public static void hideSoftInput(Activity activity) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document the parameter(s): activity     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
36
        View view = activity.getWindow().peekDecorView();
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
37
        if (view != null) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
38
            InputMethodManager inputmanger = (InputMethodManager) activity
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
39
                    .getSystemService(Context.INPUT_METHOD_SERVICE);
40
            inputmanger.hideSoftInputFromWindow(view.getWindowToken(), 0);
48
     * @param edit    输入框
49
     */
50
    public static void hideSoftInput(Context context, EditText edit) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
51
        edit.clearFocus();
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
52
        InputMethodManager inputmanger = (InputMethodManager) context
53
                .getSystemService(Context.INPUT_METHOD_SERVICE);
60
     * <p>参照以下注释代码</p>
61
     */
62
    public static void clickBlankArea2HideSoftInput0() {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
63
        Log.i("tips", "U should copy the following code.");
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
64
        /*
65
        @Override
66
        public boolean onTouchEvent (MotionEvent event){
This block of commented-out lines of code should be removed.     NEW     squid:CommentedOutCodeLine  
Sections of code should not be "commented out"
67
            if (null != this.getCurrentFocus()) {
68
                InputMethodManager mInputMethodManager = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
80
     * <p>参照以下注释代码</p>
81
     */
82
    public static void clickBlankArea2HideSoftInput1() {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
83
        Log.i("tips", "U should copy the following code.");
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
84
        /*
85
        @Override
86
        public boolean dispatchTouchEvent(MotionEvent ev) {
This block of commented-out lines of code should be removed.     NEW     squid:CommentedOutCodeLine  
Sections of code should not be "commented out"
87
            if (ev.getAction() == MotionEvent.ACTION_DOWN) {
88
                View v = getCurrentFocus();
125
     * @return
126
     */
127
    public static boolean showSoftInput(View view) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
128
        InputMethodManager imm = (InputMethodManager) view.getContext()
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
129
                .getSystemService(Context.INPUT_METHOD_SERVICE);
130
        return imm.showSoftInput(view, InputMethodManager.SHOW_FORCED);
137
     * @param edit    输入框
138
     */
139
    public static void showSoftInput(Context context, EditText edit) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
140
        edit.setFocusable(true);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
141
        edit.setFocusableInTouchMode(true);
142
        edit.requestFocus();
151
     * @param context 上下文
152
     */
153
    public static void toggleSoftInput(Context context) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
154
        InputMethodManager imm = (InputMethodManager) context
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
155
                .getSystemService(Context.INPUT_METHOD_SERVICE);
156
        imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
163
     * @return {@code true}: 显示<br>{@code false}: 不显示
164
     */
165
    public static boolean isShowSoftInput(Context context) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
166
        return ((InputMethodManager) context
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
167
                .getSystemService(Context.INPUT_METHOD_SERVICE)).isActive();
168
    }
120
New issues
Add or update the header of this file.     NEW     squid:S1451
Copyright and license headers should be defined
1
package com.blankj.utilcode.utils;
2

                  
21
 * </pre>
22
 */
23
public class LogUtils {
Make this class "final" or add a public constructor.     NEW     squid:S2974  
Classes without "public" constructors should be "final"
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
24

                  
25
    private LogUtils() {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Make this line start at column 3.     NEW     squid:IndentationCheck  
Source code should be indented consistently
26
        throw new UnsupportedOperationException("u can't instantiate me...");
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
27
    }
28

                  
29
    private static Boolean LOG_SWITCH = true; // 日志文件总开关
Rename this field "LOG_SWITCH" to match the regular expression '^[a-z][a-zA-Z0-9]*$'.     NEW     squid:S3008  
Static non-final field names should comply with a naming convention
Move this variable to comply with Java Code Conventions.     NEW     squid:S1213  
The members of an interface declaration or class should appear in a pre-defined order
30
    private static Boolean LOG_TO_FILE = false; // 日志写入文件开关
Rename this field "LOG_TO_FILE" to match the regular expression '^[a-z][a-zA-Z0-9]*$'.     NEW     squid:S3008  
Static non-final field names should comply with a naming convention
Move this variable to comply with Java Code Conventions.     NEW     squid:S1213  
The members of an interface declaration or class should appear in a pre-defined order
31
    private static String LOG_TAG = "TAG"; // 默认的tag
Rename this field "LOG_TAG" to match the regular expression '^[a-z][a-zA-Z0-9]*$'.     NEW     squid:S3008  
Static non-final field names should comply with a naming convention
Move this variable to comply with Java Code Conventions.     NEW     squid:S1213  
The members of an interface declaration or class should appear in a pre-defined order
32
    private static char LOG_TYPE = 'v';// 输入日志类型,v代表输出所有信息,w则只输出警告...
Rename this field "LOG_TYPE" to match the regular expression '^[a-z][a-zA-Z0-9]*$'.     NEW     squid:S3008  
Static non-final field names should comply with a naming convention
Move this variable to comply with Java Code Conventions.     NEW     squid:S1213  
The members of an interface declaration or class should appear in a pre-defined order
33
    private static int LOG_SAVE_DAYS = 7;// sd卡中日志文件的最多保存天数
Rename this field "LOG_SAVE_DAYS" to match the regular expression '^[a-z][a-zA-Z0-9]*$'.     NEW     squid:S3008  
Static non-final field names should comply with a naming convention
Move this variable to comply with Java Code Conventions.     NEW     squid:S1213  
The members of an interface declaration or class should appear in a pre-defined order
Assign this magic number 7 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
34

                  
35
    private final static SimpleDateFormat LOG_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");// 日志的输出格式
Reorder the modifiers to comply with the Java Language Specification.     NEW     squid:ModifiersOrderCheck  
Modifiers should be declared in the correct order
Move this variable to comply with Java Code Conventions.     NEW     squid:S1213  
The members of an interface declaration or class should appear in a pre-defined order
Make "LOG_FORMAT" an instance variable.     NEW     squid:S2885  
Non-thread-safe fields should not be static
36
    private final static SimpleDateFormat FILE_SUFFIX = new SimpleDateFormat("yyyy-MM-dd");// 日志文件格式
Reorder the modifiers to comply with the Java Language Specification.     NEW     squid:ModifiersOrderCheck  
Modifiers should be declared in the correct order
Move this variable to comply with Java Code Conventions.     NEW     squid:S1213  
The members of an interface declaration or class should appear in a pre-defined order
Make "FILE_SUFFIX" an instance variable.     NEW     squid:S2885  
Non-thread-safe fields should not be static
37
    private static String LOG_FILE_PATH; // 日志文件保存路径
Rename this field "LOG_FILE_PATH" to match the regular expression '^[a-z][a-zA-Z0-9]*$'.     NEW     squid:S3008  
Static non-final field names should comply with a naming convention
Move this variable to comply with Java Code Conventions.     NEW     squid:S1213  
The members of an interface declaration or class should appear in a pre-defined order
38
    private static String LOG_FILE_NAME;// 日志文件保存名称
Rename this field "LOG_FILE_NAME" to match the regular expression '^[a-z][a-zA-Z0-9]*$'.     NEW     squid:S3008  
Static non-final field names should comply with a naming convention
Move this variable to comply with Java Code Conventions.     NEW     squid:S1213  
The members of an interface declaration or class should appear in a pre-defined order
39

                  
40
    public static void init(Context context) { // 在Application中初始化
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document this public method.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
41
        LOG_FILE_PATH = Environment.getExternalStorageDirectory().getPath() + File.separator + context.getPackageName();
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Synchronize this lazy initialization of 'LOG_FILE_PATH'     NEW     squid:S2444  
Lazy initialization of "static" fields should be "synchronized"
42
        LOG_FILE_NAME = "Log";
Synchronize this lazy initialization of 'LOG_FILE_NAME'     NEW     squid:S2444  
Lazy initialization of "static" fields should be "synchronized"
43
    }
44

                  
46
     * Warn
47
     *********************************/
48
    public static void w(Object msg) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document the parameter(s): msg     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
49
        w(LOG_TAG, msg);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
50
    }
51

                  
52
    public static void w(String tag, Object msg) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document this public method.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
53
        w(tag, msg, null);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
54
    }
55

                  
56
    public static void w(String tag, Object msg, Throwable tr) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document this public method.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
57
        log(tag, msg.toString(), tr, 'w');
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
58
    }
59

                  
61
     * Error
62
     ********************************/
63
    public static void e(Object msg) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document the parameter(s): msg     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
64
        e(LOG_TAG, msg);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
65
    }
66

                  
67
    public static void e(String tag, Object msg) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document this public method.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
68
        e(tag, msg, null);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
69
    }
70

                  
71
    public static void e(String tag, Object msg, Throwable tr) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document this public method.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
72
        log(tag, msg.toString(), tr, 'e');
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
73
    }
74

                  
76
     * Debug
77
     ********************************/
78
    public static void d(Object msg) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document the parameter(s): msg     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
79
        d(LOG_TAG, msg);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
80
    }
81

                  
82
    public static void d(String tag, Object msg) {// 调试信息
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document this public method.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
83
        d(tag, msg, null);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
84
    }
85

                  
86
    public static void d(String tag, Object msg, Throwable tr) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document this public method.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
87
        log(tag, msg.toString(), tr, 'd');
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
88
    }
89

                  
91
     * Info
92
     *********************************/
93
    public static void i(Object msg) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document the parameter(s): msg     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
94
        i(LOG_TAG, msg);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
95
    }
96

                  
97
    public static void i(String tag, Object msg) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document this public method.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
98
        i(tag, msg, null);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
99
    }
100

                  
101
    public static void i(String tag, Object msg, Throwable tr) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document this public method.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
102
        log(tag, msg.toString(), tr, 'i');
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
103
    }
104

                  
106
     * Verbose
107
     ********************************/
108
    public static void v(Object msg) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document the parameter(s): msg     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
109
        v(LOG_TAG, msg);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
110
    }
111

                  
112
    public static void v(String tag, Object msg) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document this public method.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
113
        v(tag, msg, null);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
114
    }
115

                  
116
    public static void v(String tag, Object msg, Throwable tr) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document this public method.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
117
        log(tag, msg.toString(), tr, 'v');
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
118
    }
119

                  
125
     * @param level
126
     */
127
    private static void log(String tag, String msg, Throwable tr, char level) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
The Cyclomatic Complexity of this method "log" is 16 which is greater than 10 authorized.     NEW     squid:MethodCyclomaticComplexity  
Methods should not be too complex
128
        if (LOG_SWITCH) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
129
            if ('e' == level && ('e' == LOG_TYPE || 'v' == LOG_TYPE)) { // 输出错误信息
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
130
                Log.e(tag, msg, tr);
Make this line start at column 9.     NEW     squid:IndentationCheck  
Source code should be indented consistently
131
            } else if ('w' == level && ('w' == LOG_TYPE || 'v' == LOG_TYPE)) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "else" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
132
                Log.w(tag, msg, tr);
Make this line start at column 9.     NEW     squid:IndentationCheck  
Source code should be indented consistently
133
            } else if ('d' == level && ('d' == LOG_TYPE || 'v' == LOG_TYPE)) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "else" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
134
                Log.d(tag, msg, tr);
Make this line start at column 9.     NEW     squid:IndentationCheck  
Source code should be indented consistently
135
            } else if ('i' == level && ('d' == LOG_TYPE || 'v' == LOG_TYPE)) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "else" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
136
                Log.i(tag, msg, tr);
Make this line start at column 9.     NEW     squid:IndentationCheck  
Source code should be indented consistently
137
            } else {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "else" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
138
                Log.v(tag, msg, tr);
Make this line start at column 9.     NEW     squid:IndentationCheck  
Source code should be indented consistently
139
            }
140
            if (LOG_TO_FILE)
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
141
                log2File(String.valueOf(level), tag, msg + tr == null ? "" : "\n" + Log.getStackTraceString(tr));
Add parentheses to make the operator precedence explicit.     NEW     squid:S864  
Limited dependence should be placed on operator precedence rules in expressions
Convert this usage of the ternary operator to an "if"/"else" structure.     NEW     squid:S1774  
The ternary operator should not be used
142
        }
143
    }
148
     * @return
149
     **/
150
    private synchronized static void log2File(String mylogtype, String tag, String text) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Reorder the modifiers to comply with the Java Language Specification.     NEW     squid:ModifiersOrderCheck  
Modifiers should be declared in the correct order
151
        Date nowtime = new Date();
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
152
        String date = FILE_SUFFIX.format(nowtime);
153
        String dateLogContent = LOG_FORMAT.format(nowtime) + ":" + mylogtype + ":" + tag + ":" + text; // 日志输出格式
154
        File destDir = new File(LOG_FILE_PATH);
155
        if (!destDir.exists()) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
156
            destDir.mkdirs();
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
157
        }
158
        File file = new File(LOG_FILE_PATH, LOG_FILE_NAME + date);
159
        try {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
160
            FileWriter filerWriter = new FileWriter(file, true);
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Close this "FileWriter".     NEW     squid:S2095  
Resources should be closed
Remove this use of "java.io.FileWriter"     NEW     squid:S1943  
Classes and methods that rely on the default system encoding should not be used
161
            BufferedWriter bufWriter = new BufferedWriter(filerWriter);
162
            bufWriter.write(dateLogContent);
164
            bufWriter.close();
165
            filerWriter.close();
166
        } catch (IOException e) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "catch" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
Either log or rethrow this exception.     NEW     squid:S1166  
Exception handlers should preserve the original exceptions
167
            e.printStackTrace();
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Use a logger to log this exception.     NEW     squid:S1148  
Throwable.printStackTrace(...) should not be called
168
        }
169
    }
172
     * 删除指定的日志文件
173
     */
174
    public static void delFile() {// 删除日志文件
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
175
        String needDelFiel = FILE_SUFFIX.format(getDateBefore());
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
176
        File file = new File(LOG_FILE_PATH, needDelFiel + LOG_FILE_NAME);
177
        if (file.exists()) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
178
            file.delete();
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Do something with the "boolean" value returned by "delete".     NEW     squid:S899  
Return values should not be ignored when they contain the operation status code
179
        }
180
    }
185
     * @return
186
     */
187
    private static Date getDateBefore() {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
188
        Date nowtime = new Date();
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
189
        Calendar now = Calendar.getInstance();
190
        now.setTime(nowtime);
117
New issues
Add or update the header of this file.     NEW     squid:S1451
Copyright and license headers should be defined
Add a new line at the end of this file.     NEW     squid:S00113
Files should contain an empty new line at the end
1
package com.blankj.utilcode.utils;
2

                  
23
 * </pre>
24
 */
25
public class NetworkUtils {
Make this class "final" or add a public constructor.     NEW     squid:S2974  
Classes without "public" constructors should be "final"
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
26

                  
27
    private NetworkUtils() {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Make this line start at column 3.     NEW     squid:IndentationCheck  
Source code should be indented consistently
28
        throw new UnsupportedOperationException("u can't instantiate me...");
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
29
    }
30

                  
31
    public static final int NETWORK_WIFI    = 1;    // wifi network
Move this variable to comply with Java Code Conventions.     NEW     squid:S1213  
The members of an interface declaration or class should appear in a pre-defined order
Move this trailing comment on the previous empty line.     NEW     squid:TrailingCommentCheck  
Comments should not be located at the end of lines of code
32
    public static final int NETWORK_4G      = 4;    // "4G" networks
Move this variable to comply with Java Code Conventions.     NEW     squid:S1213  
The members of an interface declaration or class should appear in a pre-defined order
Move this trailing comment on the previous empty line.     NEW     squid:TrailingCommentCheck  
Comments should not be located at the end of lines of code
33
    public static final int NETWORK_3G      = 3;    // "3G" networks
Move this variable to comply with Java Code Conventions.     NEW     squid:S1213  
The members of an interface declaration or class should appear in a pre-defined order
Move this trailing comment on the previous empty line.     NEW     squid:TrailingCommentCheck  
Comments should not be located at the end of lines of code
34
    public static final int NETWORK_2G      = 2;    // "2G" networks
Move this variable to comply with Java Code Conventions.     NEW     squid:S1213  
The members of an interface declaration or class should appear in a pre-defined order
Move this trailing comment on the previous empty line.     NEW     squid:TrailingCommentCheck  
Comments should not be located at the end of lines of code
35
    public static final int NETWORK_UNKNOWN = 5;    // unknown network
Move this variable to comply with Java Code Conventions.     NEW     squid:S1213  
The members of an interface declaration or class should appear in a pre-defined order
Move this trailing comment on the previous empty line.     NEW     squid:TrailingCommentCheck  
Comments should not be located at the end of lines of code
36
    public static final int NETWORK_NO      = -1;   // no network
Move this variable to comply with Java Code Conventions.     NEW     squid:S1213  
The members of an interface declaration or class should appear in a pre-defined order
Move this trailing comment on the previous empty line.     NEW     squid:TrailingCommentCheck  
Comments should not be located at the end of lines of code
37

                  
38
    private static final int NETWORK_TYPE_GSM = 16;
Move this variable to comply with Java Code Conventions.     NEW     squid:S1213  
The members of an interface declaration or class should appear in a pre-defined order
39
    private static final int NETWORK_TYPE_TD_SCDMA = 17;
Move this variable to comply with Java Code Conventions.     NEW     squid:S1213  
The members of an interface declaration or class should appear in a pre-defined order
40
    private static final int NETWORK_TYPE_IWLAN = 18;
Move this variable to comply with Java Code Conventions.     NEW     squid:S1213  
The members of an interface declaration or class should appear in a pre-defined order
41

                  
42
    private static final String CMCC_ISP  = "46000"; //中国移动
Move this variable to comply with Java Code Conventions.     NEW     squid:S1213  
The members of an interface declaration or class should appear in a pre-defined order
43
    private static final String CMCC2_ISP = "46002";//中国移动
Move this variable to comply with Java Code Conventions.     NEW     squid:S1213  
The members of an interface declaration or class should appear in a pre-defined order
44
    private static final String CU_ISP    = "46001";   //中国联通
Move this variable to comply with Java Code Conventions.     NEW     squid:S1213  
The members of an interface declaration or class should appear in a pre-defined order
45
    private static final String CT_ISP    = "46003";   //中国电信
Move this variable to comply with Java Code Conventions.     NEW     squid:S1213  
The members of an interface declaration or class should appear in a pre-defined order
46

                  
47
    /**
51
     * @param context 上下文
52
     */
53
    public static void openWirelessSettings(Context context) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
54
        if (android.os.Build.VERSION.SDK_INT > 10) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Assign this magic number 10 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
55
            context.startActivity(new Intent(android.provider.Settings.ACTION_SETTINGS));
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
56
        } else {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "else" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
57
            context.startActivity(new Intent(android.provider.Settings.ACTION_WIRELESS_SETTINGS));
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
58
        }
59
    }
65
     * @return NetworkInfo
66
     */
67
    private static NetworkInfo getActiveNetworkInfo(Context context) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
68
        ConnectivityManager cm = (ConnectivityManager) context
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
69
                .getSystemService(Context.CONNECTIVITY_SERVICE);
70
        return cm.getActiveNetworkInfo();
78
     * @return {@code true}: 可用<br>{@code false}: 不可用
79
     */
80
    public static boolean isAvailable(Context context) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
81
        NetworkInfo info = getActiveNetworkInfo(context);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
82
        return info != null && info.isAvailable();
83
    }
90
     * @return {@code true}: 是<br>{@code false}: 否
91
     */
92
    public static boolean isConnected(Context context) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
93
        NetworkInfo info = getActiveNetworkInfo(context);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
94
        return info != null && info.isConnected();
95
    }
102
     * @return {@code true}: 是<br>{@code false}: 否
103
     */
104
    public static boolean is4G(Context context) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
105
        NetworkInfo info = getActiveNetworkInfo(context);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
106
        return info != null && info.isAvailable() && info.getSubtype() == TelephonyManager.NETWORK_TYPE_LTE;
107
    }
114
     * @return {@code true}: 连接<br>{@code false}: 未连接
115
     */
116
    public static boolean isWifiConnected(Context context) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
117
        ConnectivityManager cm = (ConnectivityManager) context
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
118
                .getSystemService(Context.CONNECTIVITY_SERVICE);
119
        return cm != null && cm.getActiveNetworkInfo() != null
128
     * @return 移动网络运营商名称
129
     */
130
    public static String getNetworkOperatorName(Context context) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
131
        TelephonyManager tm = (TelephonyManager) context
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
132
                .getSystemService(Context.TELEPHONY_SERVICE);
133
        String np = tm != null ? tm.getNetworkOperatorName() : null;
Convert this usage of the ternary operator to an "if"/"else" structure.     NEW     squid:S1774  
The ternary operator should not be used
134
        String teleCompany = "unknown";
135
        if (np != null) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
136
            if (np.equals(CMCC_ISP) || np.equals(CMCC2_ISP)) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
137
                teleCompany = "中国移动";
Make this line start at column 9.     NEW     squid:IndentationCheck  
Source code should be indented consistently
138
            } else if (np.startsWith(CU_ISP)) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "else" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
139
                teleCompany = "中国联通";
Make this line start at column 9.     NEW     squid:IndentationCheck  
Source code should be indented consistently
140
            } else if (np.startsWith(CT_ISP)) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "else" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
141
                teleCompany = "中国电信";
Make this line start at column 9.     NEW     squid:IndentationCheck  
Source code should be indented consistently
142
            }
143
        }
157
     * </ul>
158
     */
159
    public static int getPhoneType(Context context) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
160
        TelephonyManager tm = (TelephonyManager) context
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
161
                .getSystemService(Context.TELEPHONY_SERVICE);
162
        return tm != null ? tm.getPhoneType() : -1;
Convert this usage of the ternary operator to an "if"/"else" structure.     NEW     squid:S1774  
The ternary operator should not be used
163
    }
164

                  
179
     * </ul>
180
     */
181
    public static int getNetWorkType(Context context) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
The Cyclomatic Complexity of this method "getNetWorkType" is 26 which is greater than 10 authorized.     NEW     squid:MethodCyclomaticComplexity  
Methods should not be too complex
182
        int netType = NETWORK_NO;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
183
        NetworkInfo info = getActiveNetworkInfo(context);
184
        if (info != null && info.isAvailable()) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
185

                  
186
            if (info.getType() == ConnectivityManager.TYPE_WIFI) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
187
                netType = NETWORK_WIFI;
Make this line start at column 9.     NEW     squid:IndentationCheck  
Source code should be indented consistently
188
            } else if (info.getType() == ConnectivityManager.TYPE_MOBILE) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "else" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
189
                switch (info.getSubtype()) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Make this line start at column 9.     NEW     squid:IndentationCheck  
Source code should be indented consistently
190

                  
191
                    case NETWORK_TYPE_GSM:
195
                    case TelephonyManager.NETWORK_TYPE_1xRTT:
196
                    case TelephonyManager.NETWORK_TYPE_IDEN:
197
                        netType = NETWORK_2G;
Make this line start at column 13.     NEW     squid:IndentationCheck  
Source code should be indented consistently
198
                        break;
199

                  
208
                    case TelephonyManager.NETWORK_TYPE_EHRPD:
209
                    case TelephonyManager.NETWORK_TYPE_HSPAP:
210
                        netType = NETWORK_3G;
Make this line start at column 13.     NEW     squid:IndentationCheck  
Source code should be indented consistently
211
                        break;
212

                  
213
                    case NETWORK_TYPE_IWLAN:
214
                    case TelephonyManager.NETWORK_TYPE_LTE:
215
                        netType = NETWORK_4G;
Make this line start at column 13.     NEW     squid:IndentationCheck  
Source code should be indented consistently
216
                        break;
217
                    default:
Reduce this switch case number of lines from 10 to at most 5, for example by extracting code into methods.     NEW     squid:S1151  
"switch case" clauses should not have too many lines
218

                  
219
                        String subtypeName = info.getSubtypeName();
Make this line start at column 13.     NEW     squid:IndentationCheck  
Source code should be indented consistently
220
                        if (subtypeName.equalsIgnoreCase("TD-SCDMA")
Refactor this code to not nest more than 3 if/for/while/switch/try statements.     NEW     squid:S134  
Control flow statements "if", "for", "while", "switch" and "try" should not be nested too deeply
Move the "TD-SCDMA" string literal on the left side of this string comparison.     NEW     squid:S1132  
Strings literals should be placed on the left side when checking for equality
221
                                || subtypeName.equalsIgnoreCase("WCDMA")
Move the "WCDMA" string literal on the left side of this string comparison.     NEW     squid:S1132  
Strings literals should be placed on the left side when checking for equality
222
                                || subtypeName.equalsIgnoreCase("CDMA2000")) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move the "CDMA2000" string literal on the left side of this string comparison.     NEW     squid:S1132  
Strings literals should be placed on the left side when checking for equality
223
                            netType = NETWORK_3G;
Make this line start at column 15.     NEW     squid:IndentationCheck  
Source code should be indented consistently
224
                        } else {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "else" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
225
                            netType = NETWORK_UNKNOWN;
Make this line start at column 15.     NEW     squid:IndentationCheck  
Source code should be indented consistently
226
                        }
227
                        break;
228
                }
229
            } else {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "else" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
230
                netType = NETWORK_UNKNOWN;
Make this line start at column 9.     NEW     squid:IndentationCheck  
Source code should be indented consistently
231
            }
232
        }
249
     * </ul>
250
     */
251
    public static String getNetWorkTypeName(Context context) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Reduce the number of returns of this method 6, down to the maximum allowed 3.     NEW     squid:S1142  
Methods should not have too many return statements
The Cyclomatic Complexity of this method "getNetWorkTypeName" is 12 which is greater than 10 authorized.     NEW     squid:MethodCyclomaticComplexity  
Methods should not be too complex
252
        switch (getNetWorkType(context)) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
253
            case NETWORK_WIFI:
254
                return "NETWORK_WIFI";
Make this line start at column 9.     NEW     squid:IndentationCheck  
Source code should be indented consistently
255
            case NETWORK_4G:
256
                return "NETWORK_4G";
Make this line start at column 9.     NEW     squid:IndentationCheck  
Source code should be indented consistently
257
            case NETWORK_3G:
258
                return "NETWORK_3G";
Make this line start at column 9.     NEW     squid:IndentationCheck  
Source code should be indented consistently
259
            case NETWORK_2G:
260
                return "NETWORK_2G";
Make this line start at column 9.     NEW     squid:IndentationCheck  
Source code should be indented consistently
261
            case NETWORK_NO:
262
                return "NETWORK_NO";
Make this line start at column 9.     NEW     squid:IndentationCheck  
Source code should be indented consistently
263
            default:
264
                return "NETWORK_UNKNOWN";
Make this line start at column 9.     NEW     squid:IndentationCheck  
Source code should be indented consistently
265
        }
266
    }
272
     * @return ip地址
273
     */
274
    public static String getIpAddress(final String domain) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
275
        try {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
276
            ExecutorService exec = Executors.newCachedThreadPool();
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
277
            Future<String> fs = exec.submit(new Callable<String>() {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Make this anonymous inner class a lambda (sonar.java.source not set. Assuming 8 or greater.)     NEW     squid:S1604  
Anonymous inner classes containing only one method should become lambdas
278
                @Override
279
                public String call() throws Exception {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
280
                    InetAddress inetAddress;
281
                    try {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Extract this nested try block into a separate method.     NEW     squid:S1141  
Try-catch blocks should not be nested
282
                        inetAddress = InetAddress.getByName(domain);
283
                        return inetAddress.getHostAddress();
284
                    } catch (UnknownHostException e) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "catch" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
Either log or rethrow this exception.     NEW     squid:S1166  
Exception handlers should preserve the original exceptions
285
                        e.printStackTrace();
Use a logger to log this exception.     NEW     squid:S1148  
Throwable.printStackTrace(...) should not be called
286
                        return null;
287
                    }
289
            });
290
            return fs.get();
291
        } catch (InterruptedException | ExecutionException e) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "catch" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
Either log or rethrow this exception.     NEW     squid:S1166  
Exception handlers should preserve the original exceptions
292
            e.printStackTrace();
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Use a logger to log this exception.     NEW     squid:S1148  
Throwable.printStackTrace(...) should not be called
293
            return null;
294
        }
80
New issues
Add or update the header of this file.     NEW     squid:S1451
Copyright and license headers should be defined
Add a new line at the end of this file.     NEW     squid:S00113
Files should contain an empty new line at the end
1
package com.blankj.utilcode.utils;
2

                  
8
import android.net.Uri;
9
import android.os.SystemClock;
10
import android.provider.Settings;
Remove this unused import 'android.provider.Settings'.     NEW     squid:UselessImportCheck  
Useless imports should be removed
11
import android.telephony.SmsManager;
12
import android.telephony.TelephonyManager;
30
 * </pre>
31
 */
32
public class PhoneUtils {
Make this class "final" or add a public constructor.     NEW     squid:S2974  
Classes without "public" constructors should be "final"
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
33

                  
34
    private PhoneUtils() {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Make this line start at column 3.     NEW     squid:IndentationCheck  
Source code should be indented consistently
35
        throw new UnsupportedOperationException("u can't instantiate me...");
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
36
    }
37

                  
42
     * @return {@code true}: 是<br>{@code false}: 否
43
     */
44
    public static boolean isPhone(Context context) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
45
        TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
46
        return tm.getPhoneType() != TelephonyManager.PHONE_TYPE_NONE;
47
    }
54
     * @return IMIE码
55
     */
56
    public static String getIMEI(Context context) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
57
        return ((TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE)).getDeviceId();
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
58
    }
59

                  
64
     * @return IMSI码
65
     */
66
    public static String getIMSI(Context context) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
67
        return ((TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE)).getSubscriberId();
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
68
    }
69

                  
89
     * VoiceMailNumber = *86<br>
90
     */
91
    public static String getPhoneStatus(Context context) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
92
        TelephonyManager tm = (TelephonyManager) context
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
93
                .getSystemService(Context.TELEPHONY_SERVICE);
94
        String str = "";
117
     * @param phoneNumber 电话号码
118
     */
119
    public static void dial(Context context, String phoneNumber) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
120
        context.startActivity(new Intent(Intent.ACTION_DIAL, Uri.parse("tel:" + phoneNumber)));
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
121
    }
122

                  
128
     * @param phoneNumber 电话号码
129
     */
130
    public static void call(Context context, String phoneNumber) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
131
        context.startActivity(new Intent("android.intent.action.CALL", Uri.parse("tel:" + phoneNumber)));
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
132
    }
133

                  
139
     * @param content     短信内容
140
     */
141
    public static void sendSms(Context context, String phoneNumber, String content) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
142
        Uri uri = Uri.parse("smsto:" + (StringUtils.isEmpty(phoneNumber) ? "" : phoneNumber));
Convert this usage of the ternary operator to an "if"/"else" structure.     NEW     squid:S1774  
The ternary operator should not be used
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
143
        Intent intent = new Intent(Intent.ACTION_SENDTO, uri);
144
        intent.putExtra("sms_body", StringUtils.isEmpty(content) ? "" : content);
Convert this usage of the ternary operator to an "if"/"else" structure.     NEW     squid:S1774  
The ternary operator should not be used
145
        context.startActivity(intent);
146
    }
154
     * @param content     短信内容
155
     */
156
    public static void sendSmsSilent(Context context, String phoneNumber, String content) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
157
        if (StringUtils.isEmpty(content)) return;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
158
        PendingIntent sentIntent = PendingIntent.getBroadcast(context, 0, new Intent(), 0);
159
        SmsManager smsManager = SmsManager.getDefault();
160
        if (content.length() >= 70) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Assign this magic number 70 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
161
            List<String> ms = smsManager.divideMessage(content);
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
162
            for (String str : ms) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
163
                smsManager.sendTextMessage(phoneNumber, null, str, sentIntent, null);
Make this line start at column 9.     NEW     squid:IndentationCheck  
Source code should be indented consistently
164
            }
165
        } else {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "else" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
166
            smsManager.sendTextMessage(phoneNumber, null, content, sentIntent, null);
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
167
        }
168
    }
176
     * @return 联系人链表
177
     */
178
    public static List<HashMap<String, String>> getAllContactInfo(Context context) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
179
        SystemClock.sleep(3000);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Assign this magic number 3000 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
180
        ArrayList<HashMap<String, String>> list = new ArrayList<HashMap<String, String>>();
Replace the type specification in this constructor call with the diamond operator ("<>"). (sonar.java.source not set. Assuming 7 or greater.)     NEW     squid:S2293  
The diamond operator ("<>") should be used
181
        // 1.获取内容解析者
182
        ContentResolver resolver = context.getContentResolver();
185
        // view_data表的地址 : data
186
        // 3.生成查询地址
187
        Uri raw_uri = Uri.parse("content://com.android.contacts/raw_contacts");
Rename this local variable name to match the regular expression '^[a-z][a-zA-Z0-9]*$'.     NEW     squid:S00117  
Local variable and method parameter names should comply with a naming convention
188
        Uri date_uri = Uri.parse("content://com.android.contacts/data");
Rename this local variable name to match the regular expression '^[a-z][a-zA-Z0-9]*$'.     NEW     squid:S00117  
Local variable and method parameter names should comply with a naming convention
189
        // 4.查询操作,先查询raw_contacts,查询contact_id
190
        // projection : 查询的字段
192
                null, null, null);
193
        // 5.解析cursor
194
        while (cursor.moveToNext()) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
195
            // 6.获取查询的数据
196
            String contact_id = cursor.getString(0);
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Rename this local variable name to match the regular expression '^[a-z][a-zA-Z0-9]*$'.     NEW     squid:S00117  
Local variable and method parameter names should comply with a naming convention
197
            // cursor.getString(cursor.getColumnIndex("contact_id"));//getColumnIndex
198
            // : 查询字段在cursor中索引值,一般都是用在查询字段比较多的时候
199
            // 判断contact_id是否为空
200
            if (!StringUtils.isEmpty(contact_id)) {//null   ""
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this trailing comment on the previous empty line.     NEW     squid:TrailingCommentCheck  
Comments should not be located at the end of lines of code
201
                // 7.根据contact_id查询view_data表中的数据
202
                // selection : 查询条件
204
                // sortOrder : 排序
205
                // 空指针: 1.null.方法 2.参数为null
206
                Cursor c = resolver.query(date_uri, new String[]{"data1",
Make this line start at column 9.     NEW     squid:IndentationCheck  
Source code should be indented consistently
207
                                "mimetype"}, "raw_contact_id=?",
208
                        new String[]{contact_id}, null);
209
                HashMap<String, String> map = new HashMap<String, String>();
Replace the type specification in this constructor call with the diamond operator ("<>"). (sonar.java.source not set. Assuming 7 or greater.)     NEW     squid:S2293  
The diamond operator ("<>") should be used
210
                // 8.解析c
211
                while (c.moveToNext()) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
212
                    // 9.获取数据
213
                    String data1 = c.getString(0);
Make this line start at column 11.     NEW     squid:IndentationCheck  
Source code should be indented consistently
214
                    String mimetype = c.getString(1);
215
                    // 10.根据类型去判断获取的data1数据并保存
216
                    if (mimetype.equals("vnd.android.cursor.item/phone_v2")) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Refactor this code to not nest more than 3 if/for/while/switch/try statements.     NEW     squid:S134  
Control flow statements "if", "for", "while", "switch" and "try" should not be nested too deeply
Move the "vnd.android.cursor.item/phone_v2" string literal on the left side of this string comparison.     NEW     squid:S1132  
Strings literals should be placed on the left side when checking for equality
217
                        // 电话
218
                        map.put("phone", data1);
Make this line start at column 13.     NEW     squid:IndentationCheck  
Source code should be indented consistently
219
                    } else if (mimetype.equals("vnd.android.cursor.item/name")) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "else" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
Move the "vnd.android.cursor.item/name" string literal on the left side of this string comparison.     NEW     squid:S1132  
Strings literals should be placed on the left side when checking for equality
220
                        // 姓名
221
                        map.put("name", data1);
Make this line start at column 13.     NEW     squid:IndentationCheck  
Source code should be indented consistently
222
                    }
223
                }
237
     * <p>参照以下注释代码</p>
238
     */
239
    public static void getContantNum() {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
240
        Log.i("tips", "U should copy the following code.");
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
241
        /*
242
        Intent intent = new Intent();
This block of commented-out lines of code should be removed.     NEW     squid:CommentedOutCodeLine  
Sections of code should not be "commented out"
243
        intent.setAction("android.intent.action.PICK");
244
        intent.setType("vnd.android.cursor.dir/phone_v2");
272
     * @param context 上下文
273
     */
274
    public static void getAllSMS(Context context) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
275
        // 1.获取短信
276
        // 1.1获取内容解析者
277
        ContentResolver resolver = context.getContentResolver();
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
278
        // 1.2获取内容提供者地址   sms,sms表的地址:null  不写
279
        // 1.3获取查询路径
284
        // selectionArgs : 查询条件的参数
285
        // sortOrder : 排序
286
        Cursor cursor = resolver.query(uri, new String[]{"address", "date", "type", "body"}, null, null, null);
Define a constant instead of duplicating this literal "address" 3 times.     NEW     squid:S1192  
String literals should not be duplicated
287
        // 设置最大进度
288
        int count = cursor.getCount();//获取短信的个数
Remove this unused "count" local variable.     NEW     squid:S1481  
Unused local variables should be removed
Remove this useless assignment to local variable "count".     NEW     squid:S1854  
Dead stores should be removed
289
        // 2.备份短信
290
        // 2.1获取xml序列器
291
        XmlSerializer xmlSerializer = Xml.newSerializer();
292
        try {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
293
            // 2.2设置xml文件保存的路径
294
            // os : 保存的位置
295
            // encoding : 编码格式
296
            xmlSerializer.setOutput(new FileOutputStream(new File("/mnt/sdcard/backupsms.xml")), "utf-8");
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
297
            // 2.3设置头信息
298
            // standalone : 是否独立保存
301
            xmlSerializer.startTag(null, "smss");
302
            // 1.5.解析cursor
303
            while (cursor.moveToNext()) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
304
                SystemClock.sleep(1000);
Make this line start at column 9.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Assign this magic number 1000 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
305
                // 2.5设置短信的标签
306
                xmlSerializer.startTag(null, "sms");
316
                xmlSerializer.endTag(null, "date");
317
                xmlSerializer.startTag(null, "type");
318
                String type = cursor.getString(2);
Assign this magic number 2 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
319
                xmlSerializer.text(type);
320
                xmlSerializer.endTag(null, "type");
321
                xmlSerializer.startTag(null, "body");
322
                String body = cursor.getString(3);
Assign this magic number 3 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
323
                xmlSerializer.text(body);
324
                xmlSerializer.endTag(null, "body");
325
                xmlSerializer.endTag(null, "sms");
326
                System.out.println("address:" + address + "   date:" + date + "  type:" + type + "  body:" + body);
Replace this usage of System.out or System.err by a logger.     NEW     squid:S106  
Standard outputs should not be used directly to log anything
327
            }
328
            xmlSerializer.endTag(null, "smss");
330
            // 2.8将数据刷新到文件中
331
            xmlSerializer.flush();
332
        } catch (Exception e) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "catch" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
Either log or rethrow this exception.     NEW     squid:S1166  
Exception handlers should preserve the original exceptions
333
            e.printStackTrace();
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Use a logger to log this exception.     NEW     squid:S1148  
Throwable.printStackTrace(...) should not be called
334
        }
335
    }
33
New issues
Add or update the header of this file.     NEW     squid:S1451
Copyright and license headers should be defined
Add a new line at the end of this file.     NEW     squid:S00113
Files should contain an empty new line at the end
1
package com.blankj.utilcode.utils;
2

                  
13
 * </pre>
14
 */
15
public class RegexUtils {
Make this class "final" or add a public constructor.     NEW     squid:S2974  
Classes without "public" constructors should be "final"
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
16

                  
17
    private RegexUtils() {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Make this line start at column 3.     NEW     squid:IndentationCheck  
Source code should be indented consistently
18
        throw new UnsupportedOperationException("u can't instantiate me...");
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
19
    }
20

                  
29
     * @return {@code true}: 匹配<br>{@code false}: 不匹配
30
     */
31
    public static boolean isMobileSimple(String string) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document the parameter(s): string     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
Document this method return value.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
32
        return isMatch(REGEX_MOBILE_SIMPLE, string);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
33
    }
34

                  
39
     * @return {@code true}: 匹配<br>{@code false}: 不匹配
40
     */
41
    public static boolean isMobileExact(String string) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
42
        return isMatch(REGEX_MOBILE_EXACT, string);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
43
    }
44

                  
49
     * @return {@code true}: 匹配<br>{@code false}: 不匹配
50
     */
51
    public static boolean isTel(String string) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
52
        return isMatch(REGEX_TEL, string);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
53
    }
54

                  
59
     * @return {@code true}: 匹配<br>{@code false}: 不匹配
60
     */
61
    public static boolean isIDCard15(String string) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
62
        return isMatch(REGEX_IDCARD15, string);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
63
    }
64

                  
69
     * @return {@code true}: 匹配<br>{@code false}: 不匹配
70
     */
71
    public static boolean isIDCard18(String string) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
72
        return isMatch(REGEX_IDCARD18, string);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
73
    }
74

                  
79
     * @return {@code true}: 匹配<br>{@code false}: 不匹配
80
     */
81
    public static boolean isEmail(String string) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
82
        return isMatch(REGEX_EMAIL, string);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
83
    }
84

                  
89
     * @return {@code true}: 匹配<br>{@code false}: 不匹配
90
     */
91
    public static boolean isURL(String string) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
92
        return isMatch(REGEX_URL, string);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
93
    }
94

                  
99
     * @return {@code true}: 匹配<br>{@code false}: 不匹配
100
     */
101
    public static boolean isChz(String string) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
102
        return isMatch(REGEX_CHZ, string);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
103
    }
104

                  
110
     * @return {@code true}: 匹配<br>{@code false}: 不匹配
111
     */
112
    public static boolean isUsername(String string) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
113
        return isMatch(REGEX_USERNAME, string);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
114
    }
115

                  
120
     * @return {@code true}: 匹配<br>{@code false}: 不匹配
121
     */
122
    public static boolean isDate(String string) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
123
        return isMatch(REGEX_DATE, string);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
124
    }
125

                  
130
     * @return {@code true}: 匹配<br>{@code false}: 不匹配
131
     */
132
    public static boolean isIP(String string) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
133
        return isMatch(REGEX_IP, string);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
134
    }
135

                  
141
     * @return {@code true}: 匹配<br>{@code false}: 不匹配
142
     */
143
    public static boolean isMatch(String regex, String string) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
144
        return !StringUtils.isEmpty(string) && Pattern.matches(regex, string);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
145
    }
146
}
71
New issues
Add or update the header of this file.     NEW     squid:S1451
Copyright and license headers should be defined
Add a new line at the end of this file.     NEW     squid:S00113
Files should contain an empty new line at the end
1
package com.blankj.utilcode.utils;
2

                  
19
 * </pre>
20
 */
21
public class SDCardUtils {
Make this class "final" or add a public constructor.     NEW     squid:S2974  
Classes without "public" constructors should be "final"
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
22

                  
23
    private SDCardUtils() {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Make this line start at column 3.     NEW     squid:IndentationCheck  
Source code should be indented consistently
24
        throw new UnsupportedOperationException("u can't instantiate me...");
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
25
    }
26

                  
30
     * @return true : 可用<br>false : 不可用
31
     */
32
    public static boolean isSDCardEnable() {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
33
        return Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState());
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
34
    }
35

                  
39
     * @return SD卡Data路径
40
     */
41
    public static String getDataPath() {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
42
        if (!isSDCardEnable()) return "sdcard unable!";
Define a constant instead of duplicating this literal "sdcard unable!" 4 times.     NEW     squid:S1192  
String literals should not be duplicated
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
43
        return Environment.getDataDirectory().getPath() + File.separator;
44
    }
50
     * @return SD卡路径
51
     */
52
    public static String getSDCardPath() {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
53
        if (!isSDCardEnable()) return "sdcard unable!";
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
54
        return Environment.getExternalStorageDirectory().getPath() + File.separator;
55
    }
60
     * @return SD卡路径
61
     */
62
    public static String getSDCardPathByCmd() {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Reduce the number of returns of this method 4, down to the maximum allowed 3.     NEW     squid:S1142  
Methods should not have too many return statements
The Cyclomatic Complexity of this method "getSDCardPathByCmd" is 12 which is greater than 10 authorized.     NEW     squid:MethodCyclomaticComplexity  
Methods should not be too complex
63
        if (!isSDCardEnable()) return "sdcard unable!";
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
64
        String cmd = "cat /proc/mounts";
65
        Runtime run = Runtime.getRuntime();
66
        BufferedReader bufferedReader = null;
67
        try {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Change this "try" to a try-with-resources. (sonar.java.source not set. Assuming 7 or greater.)     NEW     squid:S2093  
Try-with-resources should be used
68
            Process p = run.exec(cmd);
Make sure "cmd" is properly sanitized before use in this OS command.     NEW     squid:S2076  
Values passed to OS commands should be sanitized
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
69
            bufferedReader = new BufferedReader(new InputStreamReader(new BufferedInputStream(p.getInputStream())));
Remove this use of constructor "InputStreamReader(InputStream)"     NEW     squid:S1943  
Classes and methods that rely on the default system encoding should not be used
70
            String lineStr;
71
            while ((lineStr = bufferedReader.readLine()) != null) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
72
                if (lineStr.contains("sdcard") && lineStr.contains(".android_secure")) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Make this line start at column 9.     NEW     squid:IndentationCheck  
Source code should be indented consistently
73
                    String[] strArray = lineStr.split(" ");
Make this line start at column 11.     NEW     squid:IndentationCheck  
Source code should be indented consistently
74
                    if (strArray.length >= 5) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Refactor this code to not nest more than 3 if/for/while/switch/try statements.     NEW     squid:S134  
Control flow statements "if", "for", "while", "switch" and "try" should not be nested too deeply
Assign this magic number 5 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
75
                        return strArray[1].replace("/.android_secure", "") + File.separator;
Make this line start at column 13.     NEW     squid:IndentationCheck  
Source code should be indented consistently
76
                    }
77
                }
78
                if (p.waitFor() != 0 && p.exitValue() == 1) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
79
                    return " 命令执行失败";
Make this line start at column 11.     NEW     squid:IndentationCheck  
Source code should be indented consistently
80
                }
81
            }
82
        } catch (Exception e) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "catch" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
Catch a list of specific exception subtypes instead.     NEW     squid:S2221  
"Exception" should not be caught when not required by called methods
Either log or rethrow this exception.     NEW     squid:S1166  
Exception handlers should preserve the original exceptions
83
            e.printStackTrace();
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Use a logger to log this exception.     NEW     squid:S1148  
Throwable.printStackTrace(...) should not be called
84
        } finally {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "finally" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
85
            FileUtils.closeIO(bufferedReader);
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
86
        }
87
        return Environment.getExternalStorageDirectory().getPath() + File.separator;
94
     */
95
    @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
96
    public static String getFreeSpace() {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
97
        if (!isSDCardEnable()) return "sdcard unable!";
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
98
        StatFs stat = new StatFs(getSDCardPath());
99
        long blockSize, availableBlocks;
Declare "availableBlocks" on a separate line.     NEW     squid:S1659  
Multiple variables should not be declared on the same line
100
        availableBlocks = stat.getAvailableBlocksLong();
101
        blockSize = stat.getBlockSizeLong();
109
     */
110
    @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
111
    public static SDCardInfo getSDCardInfo() {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
112
        SDCardInfo sd = new SDCardInfo();
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
113
        String state = Environment.getExternalStorageState();
114
        if (Environment.MEDIA_MOUNTED.equals(state)) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
115
            sd.isExist = true;
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
116
            File sdcardDir = Environment.getExternalStorageDirectory();
117
            StatFs sf = new StatFs(sdcardDir.getPath());
127
    }
128

                  
129
    private static class SDCardInfo {
Reduce this class from 26 to the maximum allowed 25 or externalize it in a public class.     NEW     squid:S2972  
Inner classes should not have too many lines
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Make this line start at column 3.     NEW     squid:IndentationCheck  
Source code should be indented consistently
130
        boolean isExist;
Explicitly declare the visibility for "isExist".     NEW     squid:S2039  
Member variable visibility should be specified
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
131
        long totalBlocks;
Explicitly declare the visibility for "totalBlocks".     NEW     squid:S2039  
Member variable visibility should be specified
132
        long freeBlocks;
Explicitly declare the visibility for "freeBlocks".     NEW     squid:S2039  
Member variable visibility should be specified
133
        long availableBlocks;
Explicitly declare the visibility for "availableBlocks".     NEW     squid:S2039  
Member variable visibility should be specified
134

                  
135
        long blockByteSize;
Explicitly declare the visibility for "blockByteSize".     NEW     squid:S2039  
Member variable visibility should be specified
136

                  
137
        long totalBytes;
Explicitly declare the visibility for "totalBytes".     NEW     squid:S2039  
Member variable visibility should be specified
138
        long freeBytes;
Explicitly declare the visibility for "freeBytes".     NEW     squid:S2039  
Member variable visibility should be specified
139
        long availableBytes;
Explicitly declare the visibility for "availableBytes".     NEW     squid:S2039  
Member variable visibility should be specified
140

                  
141
        @Override
142
        public String toString() {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
143
            return "SDCardInfo{" +
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
144
                    "isExist=" + isExist +
145
                    ", totalBlocks=" + totalBlocks +
46
New issues
Add or update the header of this file.     NEW     squid:S1451
Copyright and license headers should be defined
Add a new line at the end of this file.     NEW     squid:S00113
Files should contain an empty new line at the end
1
package com.blankj.utilcode.utils;
2

                  
14
 * </pre>
15
 */
16
public class SPUtils {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
17

                  
18
    private SharedPreferences sp;
Make this line start at column 3.     NEW     squid:IndentationCheck  
Source code should be indented consistently
19
    private SharedPreferences.Editor editor;
20

                  
26
     * @param spName  spName
27
     */
28
    public SPUtils(Context context, String spName) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
29
        sp = context.getSharedPreferences(spName, Context.MODE_PRIVATE);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
30
        editor = sp.edit();
31
        editor.apply();
38
     * @param value 值
39
     */
40
    public void putString(String key, String value) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
41
        editor.putString(key, value).apply();
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
42
    }
43

                  
48
     * @return 存在返回对应值,不存在返回默认值{@code null}
49
     */
50
    public String getString(String key) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
51
        return getString(key, null);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
52
    }
53

                  
59
     * @return 存在返回对应值,不存在返回默认值{@code defaultValue}
60
     */
61
    public String getString(String key, String defaultValue) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
62
        return sp.getString(key, defaultValue);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
63
    }
64

                  
69
     * @param value 值
70
     */
71
    public void putInt(String key, int value) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
72
        editor.putInt(key, value).apply();
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
73
    }
74

                  
79
     * @return 存在返回对应值,不存在返回默认值-1
80
     */
81
    public int getInt(String key) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
82
        return getInt(key, -1);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
83
    }
84

                  
90
     * @return 存在返回对应值,不存在返回默认值{@code defaultValue}
91
     */
92
    public int getInt(String key, int defaultValue) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
93
        return sp.getInt(key, defaultValue);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
94
    }
95

                  
100
     * @param value 值
101
     */
102
    public void putLong(String key, long value) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
103
        editor.putLong(key, value).apply();
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
104
    }
105

                  
110
     * @return 存在返回对应值,不存在返回默认值-1
111
     */
112
    public long getLong(String key) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
113
        return getLong(key, -1L);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
114
    }
115

                  
121
     * @return 存在返回对应值,不存在返回默认值{@code defaultValue}
122
     */
123
    public long getLong(String key, long defaultValue) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
124
        return sp.getLong(key, defaultValue);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
125
    }
126

                  
131
     * @param value 值
132
     */
133
    public void putFloat(String key, float value) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
134
        editor.putFloat(key, value).apply();
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
135
    }
136

                  
141
     * @return 存在返回对应值,不存在返回默认值-1
142
     */
143
    public float getFloat(String key) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
144
        return getFloat(key, -1f);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Upper-case this literal "f" suffix.     NEW     squid:S818  
Literal suffixes should be upper case
145
    }
146

                  
152
     * @return 存在返回对应值,不存在返回默认值{@code defaultValue}
153
     */
154
    public float getFloat(String key, float defaultValue) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
155
        return sp.getFloat(key, defaultValue);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
156
    }
157

                  
162
     * @param value 值
163
     */
164
    public void putBoolean(String key, boolean value) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
165
        editor.putBoolean(key, value).apply();
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
166
    }
167

                  
172
     * @return 存在返回对应值,不存在返回默认值{@code false}
173
     */
174
    public boolean getBoolean(String key) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
175
        return getBoolean(key, false);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
176
    }
177

                  
183
     * @return 存在返回对应值,不存在返回默认值{@code defaultValue}
184
     */
185
    public boolean getBoolean(String key, boolean defaultValue) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
186
        return sp.getBoolean(key, defaultValue);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
187
    }
188

                  
192
     * @return Map对象
193
     */
194
    public Map<String, ?> getAll() {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Remove usage of generic wildcard type.     NEW     squid:S1452  
Generic wildcard types should not be used in return parameters
195
        return sp.getAll();
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
196
    }
197

                  
201
     * @param key 键
202
     */
203
    public void remove(String key) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
204
        editor.remove(key).apply();
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
205
    }
206

                  
211
     * @return {@code true}: 存在<br>{@code false}: 不存在
212
     */
213
    public boolean contains(String key) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
214
        return sp.contains(key);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
215
    }
216

                  
218
     * SP中清除所有数据
219
     */
220
    public void clear() {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
221
        editor.clear().apply();
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
222
    }
223
}
37
New issues
Add or update the header of this file.     NEW     squid:S1451
Copyright and license headers should be defined
Add a new line at the end of this file.     NEW     squid:S00113
Files should contain an empty new line at the end
1
package com.blankj.utilcode.utils;
2

                  
20
 * </pre>
21
 */
22
public class ScreenUtils {
Make this class "final" or add a public constructor.     NEW     squid:S2974  
Classes without "public" constructors should be "final"
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
23

                  
24
    private ScreenUtils() {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Make this line start at column 3.     NEW     squid:IndentationCheck  
Source code should be indented consistently
25
        throw new UnsupportedOperationException("u can't instantiate me...");
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
26
    }
27

                  
32
     * @return 屏幕宽px
33
     */
34
    public static int getScreenWidth(Context context) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
35
        WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
36
        DisplayMetrics dm = new DisplayMetrics();// 创建了一张白纸
37
        windowManager.getDefaultDisplay().getMetrics(dm);// 给白纸设置宽高
45
     * @return 屏幕高px
46
     */
47
    public static int getScreenHeight(Context context) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
48
        WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
49
        DisplayMetrics dm = new DisplayMetrics();// 创建了一张白纸
50
        windowManager.getDefaultDisplay().getMetrics(dm);// 给白纸设置宽高
62
     * @param activity activity
63
     */
64
    public static void setLandscape(Activity activity) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
65
        activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
66
    }
67

                  
71
     * @param activity activity
72
     */
73
    public static void setPortrait(Activity activity) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
74
        activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
75
    }
76

                  
81
     * @return {@code true}: 是<br>{@code false}: 否
82
     */
83
    public static boolean isLandscape(Context context) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
84
        return context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
85
    }
86

                  
91
     * @return {@code true}: 是<br>{@code false}: 否
92
     */
93
    public static boolean isPortrait(Context context) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
94
        return context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
95
    }
96

                  
101
     * @return 屏幕旋转角度
102
     */
103
    public static int getScreenRotation(Activity activity) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Reduce the number of returns of this method 4, down to the maximum allowed 3.     NEW     squid:S1142  
Methods should not have too many return statements
104
        switch (activity.getWindowManager().getDefaultDisplay().getRotation()) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
105
            default:
Move this default to the end of the switch.     NEW     squid:SwitchLastCaseIsDefaultCheck  
"switch" statements should end with "default" clauses
106
            case Surface.ROTATION_0:
107
                return 0;
Make this line start at column 9.     NEW     squid:IndentationCheck  
Source code should be indented consistently
108
            case Surface.ROTATION_90:
109
                return 90;
Make this line start at column 9.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Assign this magic number 90 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
110
            case Surface.ROTATION_180:
111
                return 180;
Make this line start at column 9.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Assign this magic number 180 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
112
            case Surface.ROTATION_270:
113
                return 270;
Make this line start at column 9.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Assign this magic number 270 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
114
        }
115
    }
121
     * @return Bitmap
122
     */
123
    public static Bitmap captureWithStatusBar(Activity activity) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
124
        View view = activity.getWindow().getDecorView();
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
125
        view.setDrawingCacheEnabled(true);
126
        view.buildDrawingCache();
139
     * @return Bitmap
140
     */
141
    public static Bitmap captureWithoutStatusBar(Activity activity) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
142
        View view = activity.getWindow().getDecorView();
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
143
        view.setDrawingCacheEnabled(true);
144
        view.buildDrawingCache();
158
     * @return {@code true}: 是<br>{@code false}: 否
159
     */
160
    public static boolean isScreenLock(Context context) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
161
        KeyguardManager km = (KeyguardManager) context
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
162
                .getSystemService(Context.KEYGUARD_SERVICE);
163
        return km.inKeyguardRestrictedInputMode();
17
New issues
Add or update the header of this file.     NEW     squid:S1451
Copyright and license headers should be defined
Add a new line at the end of this file.     NEW     squid:S00113
Files should contain an empty new line at the end
1
package com.blankj.utilcode.utils;
2

                  
5
import android.content.ComponentName;
6
import android.content.Context;
7
import android.content.Intent;
Remove this unused import 'android.content.Intent'.     NEW     squid:UselessImportCheck  
Useless imports should be removed
8
import android.content.pm.ResolveInfo;
Remove this unused import 'android.content.pm.ResolveInfo'.     NEW     squid:UselessImportCheck  
Useless imports should be removed
9
import android.os.Bundle;
Remove this unused import 'android.os.Bundle'.     NEW     squid:UselessImportCheck  
Useless imports should be removed
10

                  
11
import java.util.List;
19
 * </pre>
20
 */
21
public class ServiceUtils {
Make this class "final" or add a public constructor.     NEW     squid:S2974  
Classes without "public" constructors should be "final"
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
22

                  
23
    private ServiceUtils() {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Make this line start at column 3.     NEW     squid:IndentationCheck  
Source code should be indented consistently
24
        throw new UnsupportedOperationException("u can't instantiate me...");
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
25
    }
26

                  
32
     * @return {@code true}: 是<br>{@code false}: 否
33
     */
34
    public static boolean isRunningService(Context context, String className) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
35
        // 进程的管理者,活动的管理者
36
        ActivityManager activityManager = (ActivityManager)
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
37
                context.getSystemService(Context.ACTIVITY_SERVICE);
38
        // 获取正在运行的服务,最多获取1000个
39
        List<RunningServiceInfo> runningServices = activityManager.getRunningServices(1000);
Assign this magic number 1000 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
40
        // 遍历集合
41
        for (RunningServiceInfo runningServiceInfo : runningServices) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
42
            ComponentName service = runningServiceInfo.service;
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
43
            if (className.equals(service.getClassName())) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
44
                return true;
Make this line start at column 9.     NEW     squid:IndentationCheck  
Source code should be indented consistently
45
            }
46
        }
88
New issues
Add or update the header of this file.     NEW     squid:S1451
Copyright and license headers should be defined
Add a new line at the end of this file.     NEW     squid:S00113
Files should contain an empty new line at the end
1
package com.blankj.utilcode.utils;
2

                  
15
 * </pre>
16
 */
17
public class ShellUtils {
Make this class "final" or add a public constructor.     NEW     squid:S2974  
Classes without "public" constructors should be "final"
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
18

                  
19
    private ShellUtils() {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Make this line start at column 3.     NEW     squid:IndentationCheck  
Source code should be indented consistently
20
        throw new UnsupportedOperationException("u can't instantiate me...");
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
21
    }
22

                  
23
    public static final String COMMAND_SU = "su";
Move this variable to comply with Java Code Conventions.     NEW     squid:S1213  
The members of an interface declaration or class should appear in a pre-defined order
24
    public static final String COMMAND_SH = "sh";
Move this variable to comply with Java Code Conventions.     NEW     squid:S1213  
The members of an interface declaration or class should appear in a pre-defined order
25
    public static final String COMMAND_EXIT = "exit\n";
Move this variable to comply with Java Code Conventions.     NEW     squid:S1213  
The members of an interface declaration or class should appear in a pre-defined order
26
    public static final String COMMAND_LINE_END = "\n";
Move this variable to comply with Java Code Conventions.     NEW     squid:S1213  
The members of an interface declaration or class should appear in a pre-defined order
27

                  
28
    /**
30
     * @return {@code true}: root<br>{@code false}: 没root
31
     */
32
    public static boolean isRoot() {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
33
        return execCmd("echo root", true, false).result == 0;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
34
    }
35

                  
41
     * @return CommandResult
42
     */
43
    public static CommandResult execCmd(String command, boolean isRoot) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
44
        return execCmd(new String[]{command}, isRoot, true);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
45
    }
46

                  
52
     * @return CommandResult
53
     */
54
    public static CommandResult execCmd(List<String> commands, boolean isRoot) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
55
        return execCmd(commands == null ? null : commands.toArray(new String[]{}), isRoot, true);
Convert this usage of the ternary operator to an "if"/"else" structure.     NEW     squid:S1774  
The ternary operator should not be used
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
56
    }
57

                  
63
     * @return CommandResult
64
     */
65
    public static CommandResult execCmd(String[] commands, boolean isRoot) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
66
        return execCmd(commands, isRoot, true);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
67
    }
68

                  
75
     * @return CommandResult
76
     */
77
    public static CommandResult execCmd(String command, boolean isRoot, boolean isNeedResultMsg) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
78
        return execCmd(new String[]{command}, isRoot, isNeedResultMsg);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
79
    }
80

                  
87
     * @return CommandResult
88
     */
89
    public static CommandResult execCmd(List<String> commands, boolean isRoot, boolean isNeedResultMsg) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
90
        return execCmd(commands == null ? null : commands.toArray(new String[]{}), isRoot, isNeedResultMsg);
Convert this usage of the ternary operator to an "if"/"else" structure.     NEW     squid:S1774  
The ternary operator should not be used
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
91
    }
92

                  
99
     * @return CommandResult
100
     */
101
    public static CommandResult execCmd(String[] commands, boolean isRoot, boolean isNeedResultMsg) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Provide multiple methods instead of using "isRoot" to determine which action to take.     NEW     squid:S2301  
Public methods should not contain selector arguments
Provide multiple methods instead of using "isNeedResultMsg" to determine which action to take.     NEW     squid:S2301  
Public methods should not contain selector arguments
The Cyclomatic Complexity of this method "execCmd" is 18 which is greater than 10 authorized.     NEW     squid:MethodCyclomaticComplexity  
Methods should not be too complex
102
        int result = -1;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
103
        if (commands == null || commands.length == 0) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
104
            return new CommandResult(result, null, null);
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
105
        }
106
        Process process = null;
110
        StringBuilder errorMsg = null;
111
        DataOutputStream os = null;
112
        try {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Change this "try" to a try-with-resources. (sonar.java.source not set. Assuming 7 or greater.)     NEW     squid:S2093  
Try-with-resources should be used
113
            process = Runtime.getRuntime().exec(isRoot ? COMMAND_SU : COMMAND_SH);
Make sure "cmd" is properly sanitized before use in this OS command.     NEW     squid:S2076  
Values passed to OS commands should be sanitized
Convert this usage of the ternary operator to an "if"/"else" structure.     NEW     squid:S1774  
The ternary operator should not be used
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
114
            os = new DataOutputStream(process.getOutputStream());
115
            for (String command : commands) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
116
                if (command == null) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Make this line start at column 9.     NEW     squid:IndentationCheck  
Source code should be indented consistently
117
                    continue;
Make this line start at column 11.     NEW     squid:IndentationCheck  
Source code should be indented consistently
118
                }
119
                os.write(command.getBytes());
Remove this use of "getBytes"     NEW     squid:S1943  
Classes and methods that rely on the default system encoding should not be used
120
                os.writeBytes(COMMAND_LINE_END);
121
                os.flush();
125

                  
126
            result = process.waitFor();
127
            if (isNeedResultMsg) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
128
                successMsg = new StringBuilder();
Make this line start at column 9.     NEW     squid:IndentationCheck  
Source code should be indented consistently
129
                errorMsg = new StringBuilder();
130
                successResult = new BufferedReader(new InputStreamReader(process.getInputStream()));
Remove this use of constructor "InputStreamReader(InputStream)"     NEW     squid:S1943  
Classes and methods that rely on the default system encoding should not be used
131
                errorResult = new BufferedReader(new InputStreamReader(process.getErrorStream()));
Remove this use of constructor "InputStreamReader(InputStream)"     NEW     squid:S1943  
Classes and methods that rely on the default system encoding should not be used
132
                String s;
133
                while ((s = successResult.readLine()) != null) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
134
                    successMsg.append(s);
Make this line start at column 11.     NEW     squid:IndentationCheck  
Source code should be indented consistently
135
                }
136
                while ((s = errorResult.readLine()) != null) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
137
                    errorMsg.append(s);
Make this line start at column 11.     NEW     squid:IndentationCheck  
Source code should be indented consistently
138
                }
139
            }
140
        } catch (Exception e) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "catch" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
Catch a list of specific exception subtypes instead.     NEW     squid:S2221  
"Exception" should not be caught when not required by called methods
Either log or rethrow this exception.     NEW     squid:S1166  
Exception handlers should preserve the original exceptions
141
            e.printStackTrace();
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Use a logger to log this exception.     NEW     squid:S1148  
Throwable.printStackTrace(...) should not be called
142
        } finally {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "finally" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
143
            try {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
144
                if (os != null) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Make this line start at column 9.     NEW     squid:IndentationCheck  
Source code should be indented consistently
145
                    os.close();
Make this line start at column 11.     NEW     squid:IndentationCheck  
Source code should be indented consistently
146
                }
147
                if (successResult != null) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
148
                    successResult.close();
Make this line start at column 11.     NEW     squid:IndentationCheck  
Source code should be indented consistently
149
                }
150
                if (errorResult != null) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
151
                    errorResult.close();
Make this line start at column 11.     NEW     squid:IndentationCheck  
Source code should be indented consistently
152
                }
153
            } catch (IOException e) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "catch" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
Either log or rethrow this exception.     NEW     squid:S1166  
Exception handlers should preserve the original exceptions
154
                e.printStackTrace();
Make this line start at column 9.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Use a logger to log this exception.     NEW     squid:S1148  
Throwable.printStackTrace(...) should not be called
155
            }
156

                  
157
            if (process != null) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
158
                process.destroy();
Make this line start at column 9.     NEW     squid:IndentationCheck  
Source code should be indented consistently
159
            }
160
        }
161
        return new CommandResult(result, successMsg == null ? null : successMsg.toString(), errorMsg == null ? null
Convert this usage of the ternary operator to an "if"/"else" structure.     NEW     squid:S1774  
The ternary operator should not be used
Convert this usage of the ternary operator to an "if"/"else" structure.     NEW     squid:S1774  
The ternary operator should not be used
162
                : errorMsg.toString());
163
    }
166
     * 返回的命令结果
167
     */
168
    public static class CommandResult {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Make this line start at column 3.     NEW     squid:IndentationCheck  
Source code should be indented consistently
169

                  
170
        /**
171
         * 结果码
172
         **/
173
        public int result;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Make result a static final constant or non-public and provide accessors if needed.     NEW     squid:ClassVariableVisibilityCheck  
Class variable fields should not have public accessibility
174
        /**
175
         * 成功的信息
176
         **/
177
        public String successMsg;
Make successMsg a static final constant or non-public and provide accessors if needed.     NEW     squid:ClassVariableVisibilityCheck  
Class variable fields should not have public accessibility
178
        /**
179
         * 错误信息
180
         **/
181
        public String errorMsg;
Make errorMsg a static final constant or non-public and provide accessors if needed.     NEW     squid:ClassVariableVisibilityCheck  
Class variable fields should not have public accessibility
182

                  
183
        public CommandResult(int result) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document this public constructor.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
184
            this.result = result;
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
185
        }
186

                  
187
        public CommandResult(int result, String successMsg, String errorMsg) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document this public constructor.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
188
            this.result = result;
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
189
            this.successMsg = successMsg;
190
            this.errorMsg = errorMsg;
68
New issues
Add or update the header of this file.     NEW     squid:S1451
Copyright and license headers should be defined
1
package com.blankj.utilcode.utils;
2

                  
15
 * </pre>
16
 */
17
public class SizeUtils {
Make this class "final" or add a public constructor.     NEW     squid:S2974  
Classes without "public" constructors should be "final"
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
18

                  
19
    private SizeUtils() {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Make this line start at column 3.     NEW     squid:IndentationCheck  
Source code should be indented consistently
20
        throw new UnsupportedOperationException("u can't instantiate me...");
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
21
    }
22

                  
28
     * @return px值
29
     */
30
    public static int dp2px(Context context, float dpValue) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
31
        final float scale = context.getResources().getDisplayMetrics().density;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
32
        return (int) (dpValue * scale + 0.5f);
Use a "double" or "BigDecimal" instead.     NEW     squid:S2164  
Math should not be performed on floats
Upper-case this literal "f" suffix.     NEW     squid:S818  
Literal suffixes should be upper case
Assign this magic number 0.5f to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
33
    }
34

                  
40
     * @return dp值
41
     */
42
    public static int px2dp(Context context, float pxValue) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
43
        final float scale = context.getResources().getDisplayMetrics().density;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
44
        return (int) (pxValue / scale + 0.5f);
Use a "double" or "BigDecimal" instead.     NEW     squid:S2164  
Math should not be performed on floats
Upper-case this literal "f" suffix.     NEW     squid:S818  
Literal suffixes should be upper case
Assign this magic number 0.5f to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
45
    }
46

                  
52
     * @return px值
53
     */
54
    public static int sp2px(Context context, float spValue) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
55
        final float fontScale = context.getResources().getDisplayMetrics().scaledDensity;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
56
        return (int) (spValue * fontScale + 0.5f);
Use a "double" or "BigDecimal" instead.     NEW     squid:S2164  
Math should not be performed on floats
Upper-case this literal "f" suffix.     NEW     squid:S818  
Literal suffixes should be upper case
Assign this magic number 0.5f to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
57
    }
58

                  
64
     * @return sp值
65
     */
66
    public static int px2sp(Context context, float pxValue) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
67
        final float fontScale = context.getResources().getDisplayMetrics().scaledDensity;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
68
        return (int) (pxValue / fontScale + 0.5f);
Use a "double" or "BigDecimal" instead.     NEW     squid:S2164  
Math should not be performed on floats
Upper-case this literal "f" suffix.     NEW     squid:S818  
Literal suffixes should be upper case
Assign this magic number 0.5f to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
69
    }
70

                  
78
     * @return 转换结果
79
     */
80
    public static float applyDimension(int unit, float value, DisplayMetrics metrics) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Reduce the number of returns of this method 7, down to the maximum allowed 3.     NEW     squid:S1142  
Methods should not have too many return statements
The Cyclomatic Complexity of this method "applyDimension" is 13 which is greater than 10 authorized.     NEW     squid:MethodCyclomaticComplexity  
Methods should not be too complex
81
        switch (unit) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Add a default case to this switch.     NEW     squid:SwitchLastCaseIsDefaultCheck  
"switch" statements should end with "default" clauses
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
82
            case TypedValue.COMPLEX_UNIT_PX:
83
                return value;
Make this line start at column 9.     NEW     squid:IndentationCheck  
Source code should be indented consistently
84
            case TypedValue.COMPLEX_UNIT_DIP:
85
                return value * metrics.density;
Make this line start at column 9.     NEW     squid:IndentationCheck  
Source code should be indented consistently
86
            case TypedValue.COMPLEX_UNIT_SP:
87
                return value * metrics.scaledDensity;
Make this line start at column 9.     NEW     squid:IndentationCheck  
Source code should be indented consistently
88
            case TypedValue.COMPLEX_UNIT_PT:
89
                return value * metrics.xdpi * (1.0f / 72);
Use a "double" or "BigDecimal" instead.     NEW     squid:S2164  
Math should not be performed on floats
Make this line start at column 9.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Upper-case this literal "f" suffix.     NEW     squid:S818  
Literal suffixes should be upper case
Assign this magic number 72 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
90
            case TypedValue.COMPLEX_UNIT_IN:
91
                return value * metrics.xdpi;
Make this line start at column 9.     NEW     squid:IndentationCheck  
Source code should be indented consistently
92
            case TypedValue.COMPLEX_UNIT_MM:
93
                return value * metrics.xdpi * (1.0f / 25.4f);
Use a "double" or "BigDecimal" instead.     NEW     squid:S2164  
Math should not be performed on floats
Make this line start at column 9.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Upper-case this literal "f" suffix.     NEW     squid:S818  
Literal suffixes should be upper case
Upper-case this literal "f" suffix.     NEW     squid:S818  
Literal suffixes should be upper case
Assign this magic number 25.4f to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
94
        }
95
        return 0;
112
     * @param view 视图
113
     */
114
    public static void forceGetViewSize(final View view, final onGetSizeListener listener) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document the parameter(s): listener     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
115
        view.post(new Runnable() {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Make this anonymous inner class a lambda (sonar.java.source not set. Assuming 8 or greater.)     NEW     squid:S1604  
Anonymous inner classes containing only one method should become lambdas
116
            @Override
117
            public void run() {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
118
                if (listener != null) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
119
                    listener.onGetSize(view);
120
                }
126
     * 获取到View尺寸的监听
127
     */
128
    public interface onGetSizeListener {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Make this line start at column 3.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Annotate the "onGetSizeListener" interface with the @FunctionalInterface annotation (sonar.java.source not set. Assuming 8 or greater.)     NEW     squid:S1609  
@FunctionalInterface annotation should be used to flag Single Abstract Method interfaces
Rename this interface name to match the regular expression '^[A-Z][a-zA-Z0-9]*$'.     NEW     squid:S00114  
Interface names should comply with a naming convention
129
        void onGetSize(View view);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Document this public method.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
130
    }
131

                  
132
    public static void setListener(onGetSizeListener listener) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
133
        mListener = listener;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Synchronize this lazy initialization of 'mListener'     NEW     squid:S2444  
Lazy initialization of "static" fields should be "synchronized"
134
    }
135

                  
136
    private static onGetSizeListener mListener;
Remove this unused "mListener" private field.     NEW     squid:S1068  
Unused "private" fields should be removed
Remove the "mListener" field and declare it as a local variable in the relevant methods.     NEW     squid:S1450  
Private fields only used as local variables in methods should become local variables
Move this variable to comply with Java Code Conventions.     NEW     squid:S1213  
The members of an interface declaration or class should appear in a pre-defined order
137

                  
138
    /**
143
     * @param view 视图
144
     */
145
    public static void measureViewInLV(View view) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Remove this unused method parameter "view".     NEW     squid:S1172  
Unused method parameters should be removed
146
        Log.i("tips", "U should copy the following code.");
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
147
        /*
148
        ViewGroup.LayoutParams p = view.getLayoutParams();
This block of commented-out lines of code should be removed.     NEW     squid:CommentedOutCodeLine  
Sections of code should not be "commented out"
149
        if (p == null) {
150
            p = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
925
New issues
Add or update the header of this file.     NEW     squid:S1451
Copyright and license headers should be defined
Add a new line at the end of this file.     NEW     squid:S00113
Files should contain an empty new line at the end
1
package com.blankj.utilcode.utils;
2

                  
11
 * </pre>
12
 */
13
public class StringUtils {
Make this class "final" or add a public constructor.     NEW     squid:S2974  
Classes without "public" constructors should be "final"
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
14

                  
15
    private StringUtils() {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Make this line start at column 3.     NEW     squid:IndentationCheck  
Source code should be indented consistently
16
        throw new UnsupportedOperationException("u can't instantiate me...");
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
17
    }
18

                  
23
     * @return {@code true}: 空<br> {@code false}: 不为空
24
     */
25
    public static boolean isEmpty(CharSequence s) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
26
        return s == null || s.length() == 0;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
27
    }
28

                  
33
     * @return {@code true}: null或全空格<br> {@code false}: 不为null且不全空格
34
     */
35
    public static boolean isSpace(String s) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
36
        return (s == null || s.trim().length() == 0);
Remove those useless parentheses.     NEW     squid:UselessParenthesesCheck  
Useless parentheses around expressions should be removed to prevent any misunderstanding
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
37
    }
38

                  
43
     * @return s为null转为长度为0字符串,否则不改变
44
     */
45
    public static String null2Length0(String s) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
46
        return s == null ? "" : s;
Convert this usage of the ternary operator to an "if"/"else" structure.     NEW     squid:S1774  
The ternary operator should not be used
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
47
    }
48

                  
53
     * @return null返回0,其他返回自身长度
54
     */
55
    public static int length(CharSequence s) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
56
        return s == null ? 0 : s.length();
Convert this usage of the ternary operator to an "if"/"else" structure.     NEW     squid:S1774  
The ternary operator should not be used
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
57
    }
58

                  
63
     * @return 首字母大写字符串
64
     */
65
    public static String upperFirstLetter(String s) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
66
        if (isEmpty(s) || !Character.isLowerCase(s.charAt(0))) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
67
            return s;
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
68
        }
69
        return String.valueOf((char) (s.charAt(0) - 32)) + s.substring(1);
Assign this magic number 32 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
70
    }
71

                  
76
     * @return 首字母小写字符串
77
     */
78
    public static String lowerFirstLetter(String s) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
79
        if (isEmpty(s) || !Character.isUpperCase(s.charAt(0))) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
80
            return s;
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
81
        }
82
        return String.valueOf((char) (s.charAt(0) + 32)) + s.substring(1);
Assign this magic number 32 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
83
    }
84

                  
89
     * @return 反转字符串
90
     */
91
    public static String reverse(String s) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
92
        int len = length(s);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
93
        if (len <= 1) return s;
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
94
        int mid = len >> 1;
95
        char[] chars = s.toCharArray();
96
        char c;
97
        for (int i = 0; i < mid; ++i) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
98
            c = chars[i];
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
99
            chars[i] = chars[len - i - 1];
100
            chars[len - i - 1] = c;
109
     * @return 半角字符串
110
     */
111
    public static String toDBC(String s) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
112
        if (isEmpty(s)) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
113
            return s;
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
114
        }
115
        char[] chars = s.toCharArray();
116
        for (int i = 0, len = chars.length; i < len; i++) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
117
            if (chars[i] == 12288) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Assign this magic number 12288 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
118
                chars[i] = ' ';
Make this line start at column 9.     NEW     squid:IndentationCheck  
Source code should be indented consistently
119
            } else if (65281 <= chars[i] && chars[i] <= 65374) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "else" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
Assign this magic number 65281 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 65374 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
120
                chars[i] = (char) (chars[i] - 65248);
Make this line start at column 9.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Assign this magic number 65248 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
121
            } else {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "else" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
122
                chars[i] = chars[i];
Remove or correct this useless self-assignment.     NEW     squid:S1656  
Variables should not be self-assigned
Make this line start at column 9.     NEW     squid:IndentationCheck  
Source code should be indented consistently
123
            }
124
        }
132
     * @return 全角字符串
133
     */
134
    public static String toSBC(String s) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
135
        if (isEmpty(s)) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
136
            return s;
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
137
        }
138
        char[] chars = s.toCharArray();
139
        for (int i = 0, len = chars.length; i < len; i++) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
140
            if (chars[i] == ' ') {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
141
                chars[i] = (char) 12288;
Make this line start at column 9.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Assign this magic number 12288 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
142
            } else if (33 <= chars[i] && chars[i] <= 126) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "else" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
Assign this magic number 33 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 126 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
143
                chars[i] = (char) (chars[i] + 65248);
Make this line start at column 9.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Assign this magic number 65248 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
144
            } else {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "else" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
145
                chars[i] = chars[i];
Remove or correct this useless self-assignment.     NEW     squid:S1656  
Variables should not be self-assigned
Make this line start at column 9.     NEW     squid:IndentationCheck  
Source code should be indented consistently
146
            }
147
        }
149
    }
150

                  
151
    private static int[] pyValue = new int[]{-20319, -20317, -20304, -20295, -20292, -20283, -20265, -20257, -20242,
Move this variable to comply with Java Code Conventions.     NEW     squid:S1213  
The members of an interface declaration or class should appear in a pre-defined order
Assign this magic number 20319 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 20317 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 20304 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 20295 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 20292 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 20283 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 20265 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 20257 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 20242 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
152
            -20230, -20051, -20036, -20032,
Assign this magic number 20230 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 20051 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 20036 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 20032 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
153
            -20026, -20002, -19990, -19986, -19982, -19976, -19805, -19784, -19775, -19774, -19763, -19756, -19751,
Assign this magic number 20026 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 20002 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 19990 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 19986 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 19982 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 19976 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 19805 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 19784 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 19775 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 19774 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 19763 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 19756 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 19751 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
154
            -19746, -19741, -19739, -19728,
Assign this magic number 19746 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 19741 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 19739 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 19728 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
155
            -19725, -19715, -19540, -19531, -19525, -19515, -19500, -19484, -19479, -19467, -19289, -19288, -19281,
Assign this magic number 19725 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 19715 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 19540 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 19531 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 19525 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 19515 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 19500 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 19484 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 19479 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 19467 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 19289 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 19288 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 19281 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
156
            -19275, -19270, -19263, -19261,
Assign this magic number 19275 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 19270 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 19263 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 19261 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
157
            -19249, -19243, -19242, -19238, -19235, -19227, -19224, -19218, -19212, -19038, -19023, -19018, -19006,
Assign this magic number 19249 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 19243 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 19242 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 19238 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 19235 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 19227 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 19224 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 19218 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 19212 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 19038 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 19023 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 19018 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 19006 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
158
            -19003, -18996, -18977, -18961,
Assign this magic number 19003 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 18996 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 18977 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 18961 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
159
            -18952, -18783, -18774, -18773, -18763, -18756, -18741, -18735, -18731, -18722, -18710, -18697, -18696,
Assign this magic number 18952 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 18783 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 18774 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 18773 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 18763 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 18756 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 18741 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 18735 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 18731 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 18722 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 18710 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 18697 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 18696 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
160
            -18526, -18518, -18501, -18490,
Assign this magic number 18526 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 18518 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 18501 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 18490 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
161
            -18478, -18463, -18448, -18447, -18446, -18239, -18237, -18231, -18220, -18211, -18201, -18184, -18183,
Assign this magic number 18478 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 18463 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 18448 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 18447 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 18446 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 18239 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 18237 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 18231 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 18220 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 18211 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 18201 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 18184 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 18183 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
162
            -18181, -18012, -17997, -17988,
Assign this magic number 18181 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 18012 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 17997 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 17988 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
163
            -17970, -17964, -17961, -17950, -17947, -17931, -17928, -17922, -17759, -17752, -17733, -17730, -17721,
Assign this magic number 17970 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 17964 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 17961 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 17950 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 17947 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 17931 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 17928 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 17922 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 17759 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 17752 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 17733 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 17730 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 17721 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
164
            -17703, -17701, -17697, -17692,
Assign this magic number 17703 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 17701 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 17697 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 17692 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
165
            -17683, -17676, -17496, -17487, -17482, -17468, -17454, -17433, -17427, -17417, -17202, -17185, -16983,
Assign this magic number 17683 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 17676 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 17496 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 17487 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 17482 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 17468 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 17454 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 17433 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 17427 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 17417 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 17202 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 17185 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 16983 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
166
            -16970, -16942, -16915, -16733,
Assign this magic number 16970 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 16942 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 16915 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 16733 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
167
            -16708, -16706, -16689, -16664, -16657, -16647, -16474, -16470, -16465, -16459, -16452, -16448, -16433,
Assign this magic number 16708 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 16706 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 16689 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 16664 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 16657 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 16647 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 16474 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 16470 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 16465 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 16459 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 16452 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 16448 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 16433 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
168
            -16429, -16427, -16423, -16419,
Assign this magic number 16429 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 16427 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 16423 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 16419 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
169
            -16412, -16407, -16403, -16401, -16393, -16220, -16216, -16212, -16205, -16202, -16187, -16180, -16171,
Assign this magic number 16412 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 16407 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 16403 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 16401 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 16393 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 16220 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 16216 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 16212 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 16205 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 16202 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 16187 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 16180 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 16171 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
170
            -16169, -16158, -16155, -15959,
Assign this magic number 16169 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 16158 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 16155 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 15959 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
171
            -15958, -15944, -15933, -15920, -15915, -15903, -15889, -15878, -15707, -15701, -15681, -15667, -15661,
Assign this magic number 15958 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 15944 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 15933 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 15920 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 15915 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 15903 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 15889 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 15878 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 15707 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 15701 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 15681 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 15667 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 15661 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
172
            -15659, -15652, -15640, -15631,
Assign this magic number 15659 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 15652 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 15640 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 15631 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
173
            -15625, -15454, -15448, -15436, -15435, -15419, -15416, -15408, -15394, -15385, -15377, -15375, -15369,
Assign this magic number 15625 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 15454 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 15448 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 15436 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 15435 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 15419 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 15416 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 15408 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 15394 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 15385 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 15377 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 15375 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 15369 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
174
            -15363, -15362, -15183, -15180,
Assign this magic number 15363 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 15362 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 15183 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 15180 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
175
            -15165, -15158, -15153, -15150, -15149, -15144, -15143, -15141, -15140, -15139, -15128, -15121, -15119,
Assign this magic number 15165 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 15158 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 15153 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 15150 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 15149 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 15144 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 15143 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 15141 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 15140 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 15139 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 15128 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 15121 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 15119 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
176
            -15117, -15110, -15109, -14941,
Assign this magic number 15117 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 15110 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 15109 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 14941 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
177
            -14937, -14933, -14930, -14929, -14928, -14926, -14922, -14921, -14914, -14908, -14902, -14894, -14889,
Assign this magic number 14937 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 14933 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 14930 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 14929 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 14928 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 14926 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 14922 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 14921 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 14914 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 14908 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 14902 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 14894 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 14889 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
178
            -14882, -14873, -14871, -14857,
Assign this magic number 14882 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 14873 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 14871 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 14857 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
179
            -14678, -14674, -14670, -14668, -14663, -14654, -14645, -14630, -14594, -14429, -14407, -14399, -14384,
Assign this magic number 14678 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 14674 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 14670 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 14668 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 14663 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 14654 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 14645 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 14630 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 14594 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 14429 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 14407 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 14399 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 14384 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
180
            -14379, -14368, -14355, -14353,
Assign this magic number 14379 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 14368 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 14355 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 14353 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
181
            -14345, -14170, -14159, -14151, -14149, -14145, -14140, -14137, -14135, -14125, -14123, -14122, -14112,
Assign this magic number 14345 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 14170 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 14159 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 14151 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 14149 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 14145 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 14140 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 14137 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 14135 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 14125 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 14123 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 14122 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 14112 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
182
            -14109, -14099, -14097, -14094,
Assign this magic number 14109 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 14099 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 14097 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 14094 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
183
            -14092, -14090, -14087, -14083, -13917, -13914, -13910, -13907, -13906, -13905, -13896, -13894, -13878,
Assign this magic number 14092 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 14090 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 14087 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 14083 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 13917 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 13914 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 13910 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 13907 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 13906 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 13905 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 13896 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 13894 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 13878 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
184
            -13870, -13859, -13847, -13831,
Assign this magic number 13870 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 13859 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 13847 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 13831 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
185
            -13658, -13611, -13601, -13406, -13404, -13400, -13398, -13395, -13391, -13387, -13383, -13367, -13359,
Assign this magic number 13658 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 13611 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 13601 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 13406 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 13404 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 13400 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 13398 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 13395 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 13391 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 13387 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 13383 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 13367 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 13359 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
186
            -13356, -13343, -13340, -13329,
Assign this magic number 13356 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 13343 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 13340 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 13329 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
187
            -13326, -13318, -13147, -13138, -13120, -13107, -13096, -13095, -13091, -13076, -13068, -13063, -13060,
Assign this magic number 13326 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 13318 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 13147 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 13138 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 13120 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 13107 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 13096 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 13095 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 13091 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 13076 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 13068 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 13063 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 13060 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
188
            -12888, -12875, -12871, -12860,
Assign this magic number 12888 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 12875 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 12871 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 12860 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
189
            -12858, -12852, -12849, -12838, -12831, -12829, -12812, -12802, -12607, -12597, -12594, -12585, -12556,
Assign this magic number 12858 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 12852 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 12849 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 12838 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 12831 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 12829 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 12812 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 12802 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 12607 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 12597 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 12594 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 12585 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 12556 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
190
            -12359, -12346, -12320, -12300,
Assign this magic number 12359 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 12346 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 12320 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 12300 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
191
            -12120, -12099, -12089, -12074, -12067, -12058, -12039, -11867, -11861, -11847, -11831, -11798, -11781,
Assign this magic number 12120 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 12099 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 12089 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 12074 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 12067 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 12058 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 12039 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 11867 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 11861 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 11847 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 11831 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 11798 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 11781 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
192
            -11604, -11589, -11536, -11358,
Assign this magic number 11604 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 11589 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 11536 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 11358 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
193
            -11340, -11339, -11324, -11303, -11097, -11077, -11067, -11055, -11052, -11045, -11041, -11038, -11024,
Assign this magic number 11340 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 11339 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 11324 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 11303 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 11097 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 11077 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 11067 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 11055 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 11052 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 11045 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 11041 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 11038 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 11024 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
194
            -11020, -11019, -11018, -11014,
Assign this magic number 11020 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 11019 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 11018 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 11014 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
195
            -10838, -10832, -10815, -10800, -10790, -10780, -10764, -10587, -10544, -10533, -10519, -10331, -10329,
Assign this magic number 10838 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 10832 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 10815 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 10800 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 10790 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 10780 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 10764 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 10587 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 10544 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 10533 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 10519 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 10331 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 10329 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
196
            -10328, -10322, -10315, -10309,
Assign this magic number 10328 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 10322 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 10315 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 10309 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
197
            -10307, -10296, -10281, -10274, -10270, -10262, -10260, -10256, -10254};
Assign this magic number 10307 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 10296 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 10281 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 10274 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 10270 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 10262 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 10260 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 10256 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 10254 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
198

                  
199
    private static String[] pyStr = new String[]{"a", "ai", "an", "ang", "ao", "ba", "bai", "ban", "bang", "bao",
Move this variable to comply with Java Code Conventions.     NEW     squid:S1213  
The members of an interface declaration or class should appear in a pre-defined order
200
            "bei", "ben", "beng", "bi", "bian",
201
            "biao", "bie", "bin", "bing", "bo", "bu", "ca", "cai", "can", "cang", "cao", "ce", "ceng", "cha", "chai",
247
     * @return 如果字符串长度是1返回的是对应的ascii码,否则返回-1
248
     */
249
    private static int oneCn2ASCII(String s) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
250
        if (s.length() != 1) return -1;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
251
        int ascii = 0;
252
        try {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
253
            byte[] bytes = s.getBytes("GB2312");
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
254
            if (bytes.length == 1) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
255
                ascii = bytes[0];
Make this line start at column 9.     NEW     squid:IndentationCheck  
Source code should be indented consistently
256
            } else if (bytes.length == 2) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "else" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
Assign this magic number 2 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
257
                int highByte = 256 + bytes[0];
Make this line start at column 9.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Assign this magic number 256 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
258
                int lowByte = 256 + bytes[1];
Assign this magic number 256 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
259
                ascii = (256 * highByte + lowByte) - 256 * 256;
Assign this magic number 256 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 256 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 256 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
260
            } else {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "else" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
261
                throw new IllegalArgumentException("Illegal resource string");
Make this line start at column 9.     NEW     squid:IndentationCheck  
Source code should be indented consistently
262
            }
263
        } catch (UnsupportedEncodingException e) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "catch" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
Either log or rethrow this exception.     NEW     squid:S1166  
Exception handlers should preserve the original exceptions
264
            e.printStackTrace();
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Use a logger to log this exception.     NEW     squid:S1148  
Throwable.printStackTrace(...) should not be called
265
        }
266
        return ascii;
273
     * @return 如果字符串长度是1返回的是对应的拼音,否则返回{@code null}
274
     */
275
    private static String oneCn2PY(String s) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
276
        int ascii = oneCn2ASCII(s);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
277
        if (ascii == -1) return null;
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
278
        String ret = null;
279
        if (0 <= ascii && ascii <= 127) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Assign this magic number 127 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
280
            ret = String.valueOf((char) ascii);
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
281
        } else {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "else" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
282
            for (int i = pyValue.length - 1; i >= 0; i--) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
283
                if (pyValue[i] <= ascii) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Make this line start at column 9.     NEW     squid:IndentationCheck  
Source code should be indented consistently
284
                    ret = pyStr[i];
Make this line start at column 11.     NEW     squid:IndentationCheck  
Source code should be indented consistently
285
                    break;
286
                }
296
     * @return 拼音
297
     */
298
    public static String getPYFirstLetter(String s) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
299
        if (isSpace(s)) return "";
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
300
        String first, py;
Declare "py" on a separate line.     NEW     squid:S1659  
Multiple variables should not be declared on the same line
301
        first = s.substring(0, 1);
302
        py = oneCn2PY(first);
303
        if (py == null) return null;
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
304
        return py.substring(0, 1);
305
    }
311
     * @return 拼音
312
     */
313
    public static String cn2PY(String s) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
314
        String hz, py;
Declare "py" on a separate line.     NEW     squid:S1659  
Multiple variables should not be declared on the same line
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
315
        StringBuilder sb = new StringBuilder();
316
        for (int i = 0; i < s.length(); i++) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
317
            hz = s.substring(i, i + 1);
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
318
            py = oneCn2PY(hz);
319
            if (py == null) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
320
                py = "?";
Make this line start at column 9.     NEW     squid:IndentationCheck  
Source code should be indented consistently
321
            }
322
            sb.append(py);
68
New issues
Add or update the header of this file.     NEW     squid:S1451
Copyright and license headers should be defined
Add a new line at the end of this file.     NEW     squid:S00113
Files should contain an empty new line at the end
1
package com.blankj.utilcode.utils;
2

                  
21
 * </pre>
22
 */
23
public class ThreadPoolUtils {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
24

                  
25
    private ThreadPoolUtils() {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Make this line start at column 3.     NEW     squid:IndentationCheck  
Source code should be indented consistently
26
        throw new UnsupportedOperationException("u can't instantiate me...");
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
27
    }
28

                  
29
    public enum Type {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Make this line start at column 3.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Document this public enum.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
30
        FixedThread,
Rename this constant name to match the regular expression '^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$'.     NEW     squid:S00115  
Constant names should comply with a naming convention
31
        CachedThread,
Rename this constant name to match the regular expression '^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$'.     NEW     squid:S00115  
Constant names should comply with a naming convention
32
        SingleThread,
Rename this constant name to match the regular expression '^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$'.     NEW     squid:S00115  
Constant names should comply with a naming convention
33
    }
34

                  
35
    private ExecutorService exec;
Move this variable to comply with Java Code Conventions.     NEW     squid:S1213  
The members of an interface declaration or class should appear in a pre-defined order
36
    private ScheduledExecutorService scheduleExec;
Move this variable to comply with Java Code Conventions.     NEW     squid:S1213  
The members of an interface declaration or class should appear in a pre-defined order
37

                  
38
    /**
42
     * @param corePoolSize 只对Fixed和Scheduled线程池起效
43
     */
44
    public ThreadPoolUtils(Type type, int corePoolSize) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
45
        // 构造有定时功能的线程池
46
        // ThreadPoolExecutor(corePoolSize, Integer.MAX_VALUE, 10L, TimeUnit.MILLISECONDS, new BlockingQueue<Runnable>)
47
        scheduleExec = Executors.newScheduledThreadPool(corePoolSize);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
48
        switch (type) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
49
            case FixedThread:
50
                // 构造一个固定线程数目的线程池
51
                // ThreadPoolExecutor(corePoolSize, corePoolSize, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>());
This block of commented-out lines of code should be removed.     NEW     squid:CommentedOutCodeLine  
Sections of code should not be "commented out"
Split this 130 characters long line (which is greater than 120 authorized).     NEW     squid:S00103  
Lines should not be too long
52
                exec = Executors.newFixedThreadPool(corePoolSize);
Make this line start at column 9.     NEW     squid:IndentationCheck  
Source code should be indented consistently
53
                break;
54
            case SingleThread:
55
                // 构造一个只支持一个线程的线程池,相当于newFixedThreadPool(1)
56
                // ThreadPoolExecutor(1, 1, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>())
57
                exec = Executors.newSingleThreadExecutor();
Make this line start at column 9.     NEW     squid:IndentationCheck  
Source code should be indented consistently
58
                break;
59
            case CachedThread:
60
                // 构造一个缓冲功能的线程池
61
                // ThreadPoolExecutor(0, Integer.MAX_VALUE, 60L, TimeUnit.SECONDS, new SynchronousQueue<Runnable>());
This block of commented-out lines of code should be removed.     NEW     squid:CommentedOutCodeLine  
Sections of code should not be "commented out"
62
                exec = Executors.newCachedThreadPool();
Make this line start at column 9.     NEW     squid:IndentationCheck  
Source code should be indented consistently
63
                break;
64
            default:
65
                exec = scheduleExec;
Make this line start at column 9.     NEW     squid:IndentationCheck  
Source code should be indented consistently
66
                break;
67
        }
74
     * @param command 命令
75
     */
76
    public void execute(Runnable command) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
77
        exec.execute(command);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
78
    }
79

                  
84
     * @param commands 命令链表
85
     */
86
    public void execute(List<Runnable> commands) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
87
        for (Runnable command : commands) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
88
            exec.execute(command);
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
89
        }
90
    }
95
     * 如果已经关闭,则调用没有作用。</p>
96
     */
97
    public void shutDown() {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
98
        exec.shutdown();
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
99
    }
100

                  
106
     * @return 等待执行的任务的列表
107
     */
108
    public List<Runnable> shutDownNow() {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
109
        return exec.shutdownNow();
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
110
    }
111

                  
115
     * @return {@code true}: 是<br>{@code false}: 否
116
     */
117
    public boolean isShutDown() {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
118
        return exec.isShutdown();
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
119
    }
120

                  
125
     * @return {@code true}: 是<br>{@code false}: 否
126
     */
127
    public boolean isTerminated() {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
128
        return exec.isTerminated();
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
129
    }
130

                  
139
     * @throws InterruptedException 终端异常
140
     */
141
    public boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
142
        return exec.awaitTermination(timeout, unit);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
143
    }
144

                  
151
     * @return 表示任务等待完成的Future, 该Future的{@code get}方法在成功完成时将会返回该任务的结果。
152
     */
153
    public <T> Future<T> submit(Callable<T> task) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
154
        return exec.submit(task);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
155
    }
156

                  
163
     * @return 表示任务等待完成的Future, 该Future的{@code get}方法在成功完成时将会返回该任务的结果。
164
     */
165
    public <T> Future<T> submit(Runnable task, T result) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
166
        return exec.submit(task, result);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
167
    }
168

                  
173
     * @return 表示任务等待完成的Future, 该Future的{@code get}方法在成功完成时将会返回null结果。
174
     */
175
    public Future<?> submit(Runnable task) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Remove usage of generic wildcard type.     NEW     squid:S1452  
Generic wildcard types should not be used in return parameters
176
        return exec.submit(task);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
177
    }
178

                  
189
     * @throws InterruptedException 如果等待时发生中断,在这种情况下取消尚未完成的任务。
190
     */
191
    public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks) throws InterruptedException {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
192
        return exec.invokeAll(tasks);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
193
    }
194

                  
209
     */
210
    public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) throws
211
            InterruptedException {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
212
        return exec.invokeAll(tasks, timeout, unit);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
213
    }
214

                  
225
     * @throws ExecutionException   如果没有任务成功完成
226
     */
227
    public <T> T invokeAny(Collection<? extends Callable<T>> tasks) throws InterruptedException, ExecutionException {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Refactor this method to throw at most one checked exception instead of: java.lang.InterruptedException, java.util.concurrent.ExecutionException     NEW     squid:S1160  
Public methods should throw at most one checked exception
228
        return exec.invokeAny(tasks);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
229
    }
230

                  
244
     * @throws TimeoutException     如果在所有任务成功完成之前给定的超时期满
245
     */
246
    public <T> T invokeAny(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) throws
Refactor this method to throw at most one checked exception instead of: java.lang.InterruptedException, java.util.concurrent.ExecutionException, java.util.concurrent.TimeoutException     NEW     squid:S1160  
Public methods should throw at most one checked exception
247
            InterruptedException, ExecutionException, TimeoutException {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
248
        return exec.invokeAny(tasks, timeout, unit);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
249
    }
250

                  
257
     * @return 表示挂起任务完成的ScheduledFuture,并且其{@code get()}方法在完成后将返回{@code null}
258
     */
259
    public ScheduledFuture<?> schedule(Runnable command, long delay, TimeUnit unit) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Remove usage of generic wildcard type.     NEW     squid:S1452  
Generic wildcard types should not be used in return parameters
260
        return scheduleExec.schedule(command, delay, unit);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
261
    }
262

                  
270
     * @return 可用于提取结果或取消的ScheduledFuture
271
     */
272
    public <V> ScheduledFuture<V> schedule(Callable<V> callable, long delay, TimeUnit unit) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
273
        return scheduleExec.schedule(callable, delay, unit);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
274
    }
275

                  
283
     * @return 表示挂起任务完成的ScheduledFuture,并且其{@code get()}方法在取消后将抛出异常
284
     */
285
    public ScheduledFuture<?> scheduleWithFixedRate(Runnable command, long initialDelay, long period, TimeUnit unit) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Remove usage of generic wildcard type.     NEW     squid:S1452  
Generic wildcard types should not be used in return parameters
286
        return scheduleExec.scheduleAtFixedRate(command, initialDelay, period, unit);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
287
    }
288

                  
296
     * @return 表示挂起任务完成的ScheduledFuture,并且其{@code get()}方法在取消后将抛出异常
297
     */
298
    public ScheduledFuture<?> scheduleWithFixedDelay(Runnable command, long initialDelay, long delay, TimeUnit unit) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Remove usage of generic wildcard type.     NEW     squid:S1452  
Generic wildcard types should not be used in return parameters
299
        return scheduleExec.scheduleWithFixedDelay(command, initialDelay, delay, unit);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
300
    }
301
}
72
New issues
Add or update the header of this file.     NEW     squid:S1451
Copyright and license headers should be defined
Add a new line at the end of this file.     NEW     squid:S00113
Files should contain an empty new line at the end
1
package com.blankj.utilcode.utils;
2

                  
17
 * </pre>
18
 */
19
public class TimeUtils {
Make this class "final" or add a public constructor.     NEW     squid:S2974  
Classes without "public" constructors should be "final"
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
20

                  
21
    private TimeUtils() {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Make this line start at column 3.     NEW     squid:IndentationCheck  
Source code should be indented consistently
22
        throw new UnsupportedOperationException("u can't instantiate me...");
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
23
    }
24

                  
179
     * </pre>
180
     */
181
    public static final SimpleDateFormat DEFAULT_SDF = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault());
Move this variable to comply with Java Code Conventions.     NEW     squid:S1213  
The members of an interface declaration or class should appear in a pre-defined order
Make "DEFAULT_SDF" an instance variable.     NEW     squid:S2885  
Non-thread-safe fields should not be static
182

                  
183

                  
189
     * @return 时间字符串
190
     */
191
    public static String milliseconds2String(long milliseconds) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
192
        return milliseconds2String(milliseconds, DEFAULT_SDF);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
193
    }
194

                  
201
     * @return 时间字符串
202
     */
203
    public static String milliseconds2String(long milliseconds, SimpleDateFormat format) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
204
        return format.format(new Date(milliseconds));
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
205
    }
206

                  
212
     * @return 毫秒时间戳
213
     */
214
    public static long string2Milliseconds(String time) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
215
        return string2Milliseconds(time, DEFAULT_SDF);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
216
    }
217

                  
224
     * @return 毫秒时间戳
225
     */
226
    public static long string2Milliseconds(String time, SimpleDateFormat format) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
227
        try {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
228
            return format.parse(time).getTime();
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
229
        } catch (ParseException e) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "catch" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
230
            e.printStackTrace();
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Use a logger to log this exception.     NEW     squid:S1148  
Throwable.printStackTrace(...) should not be called
231
        }
232
        return -1;
240
     * @return Date类型
241
     */
242
    public static Date string2Date(String time) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
243
        return string2Date(time, DEFAULT_SDF);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
244
    }
245

                  
252
     * @return Date类型
253
     */
254
    public static Date string2Date(String time, SimpleDateFormat format) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
255
        return new Date(string2Milliseconds(time, format));
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
256
    }
257

                  
263
     * @return 时间字符串
264
     */
265
    public static String date2String(Date time) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
266
        return date2String(time, DEFAULT_SDF);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
267
    }
268

                  
275
     * @return 时间字符串
276
     */
277
    public static String date2String(Date time, SimpleDateFormat format) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
278
        return format.format(time);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
279
    }
280

                  
285
     * @return 毫秒时间戳
286
     */
287
    public static long date2Milliseconds(Date time) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
288
        return time.getTime();
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
289
    }
290

                  
295
     * @return Date类型时间
296
     */
297
    public static Date milliseconds2Date(long milliseconds) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
298
        return new Date(milliseconds);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
299
    }
300

                  
312
     * @return unit时间戳
313
     */
314
    private static long milliseconds2Unit(long milliseconds, TimeUnit unit) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Reduce the number of returns of this method 6, down to the maximum allowed 3.     NEW     squid:S1142  
Methods should not have too many return statements
The Cyclomatic Complexity of this method "milliseconds2Unit" is 11 which is greater than 10 authorized.     NEW     squid:MethodCyclomaticComplexity  
Methods should not be too complex
315
        switch (unit) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Add a default case to this switch.     NEW     squid:SwitchLastCaseIsDefaultCheck  
"switch" statements should end with "default" clauses
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
316
            case MSEC:
317
                return milliseconds / MSEC;
Make this line start at column 9.     NEW     squid:IndentationCheck  
Source code should be indented consistently
318
            case SEC:
319
                return milliseconds / SEC;
Make this line start at column 9.     NEW     squid:IndentationCheck  
Source code should be indented consistently
320
            case MIN:
321
                return milliseconds / MIN;
Make this line start at column 9.     NEW     squid:IndentationCheck  
Source code should be indented consistently
322
            case HOUR:
323
                return milliseconds / HOUR;
Make this line start at column 9.     NEW     squid:IndentationCheck  
Source code should be indented consistently
324
            case DAY:
325
                return milliseconds / DAY;
Make this line start at column 9.     NEW     squid:IndentationCheck  
Source code should be indented consistently
326
        }
327
        return -1;
343
     * @return unit时间戳
344
     */
345
    public static long getIntervalTime(String time0, String time1, TimeUnit unit) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
346
        return getIntervalTime(time0, time1, unit, DEFAULT_SDF);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
347
    }
348

                  
363
     * @return unit时间戳
364
     */
365
    public static long getIntervalTime(String time0, String time1, TimeUnit unit, SimpleDateFormat format) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
366
        return Math.abs(milliseconds2Unit(string2Milliseconds(time0, format)
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
367
                - string2Milliseconds(time1, format), unit));
368
    }
383
     * @return unit时间戳
384
     */
385
    public static long getIntervalTime(Date time0, Date time1, TimeUnit unit) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
386
        return Math.abs(milliseconds2Unit(date2Milliseconds(time1)
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
387
                - date2Milliseconds(time0), unit));
388
    }
393
     * @return 毫秒时间戳
394
     */
395
    public static long getCurTimeMills() {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
396
        return System.currentTimeMillis();
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
397
    }
398

                  
403
     * @return 时间字符串
404
     */
405
    public static String getCurTimeString() {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
406
        return date2String(new Date());
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
407
    }
408

                  
414
     * @return 时间字符串
415
     */
416
    public static String getCurTimeString(SimpleDateFormat format) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
417
        return date2String(new Date(), format);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
418
    }
419

                  
424
     * @return Date类型时间
425
     */
426
    public static Date getCurTimeDate() {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
427
        return new Date();
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
428
    }
429

                  
442
     * @return unit时间戳
443
     */
444
    public static long getIntervalByNow(String time, TimeUnit unit) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
445
        return getIntervalByNow(time, unit, DEFAULT_SDF);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
446
    }
447

                  
461
     * @return unit时间戳
462
     */
463
    public static long getIntervalByNow(String time, TimeUnit unit, SimpleDateFormat format) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
464
        return getIntervalTime(getCurTimeString(), time, unit, format);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
465
    }
466

                  
479
     * @return unit时间戳
480
     */
481
    public static long getIntervalByNow(Date time, TimeUnit unit) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
482
        return getIntervalTime(getCurTimeDate(), time, unit);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
483
    }
484

                  
489
     * @return {@code true}: 闰年<br>{@code false}: 平年
490
     */
491
    public static boolean isLeapYear(int year) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
492
        return year % 4 == 0 && year % 100 != 0 || year % 400 == 0;
Add parentheses to make the operator precedence explicit.     NEW     squid:S864  
Limited dependence should be placed on operator precedence rules in expressions
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Assign this magic number 4 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 100 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 400 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
493
    }
494
}
101
New issues
Add or update the header of this file.     NEW     squid:S1451
Copyright and license headers should be defined
Add a new line at the end of this file.     NEW     squid:S00113
Files should contain an empty new line at the end
1
package com.blankj.utilcode.utils;
2

                  
14
 * </pre>
15
 */
16
public class ToastUtils {
Make this class "final" or add a public constructor.     NEW     squid:S2974  
Classes without "public" constructors should be "final"
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
17

                  
18
    private ToastUtils() {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Make this line start at column 3.     NEW     squid:IndentationCheck  
Source code should be indented consistently
19
        throw new UnsupportedOperationException("u can't instantiate me...");
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
20
    }
21

                  
22
    private static Toast sToast;
Move this variable to comply with Java Code Conventions.     NEW     squid:S1213  
The members of an interface declaration or class should appear in a pre-defined order
23
    private static Handler sHandler = new Handler(Looper.getMainLooper());
Move this variable to comply with Java Code Conventions.     NEW     squid:S1213  
The members of an interface declaration or class should appear in a pre-defined order
24
    /**
25
     * <p>当连续弹出吐司时,是要弹出新吐司还是只修改文本内容</p>
27
     * <p>如果为{@code false}的话可用来做显示任意时长的吐司</p>
28
     */
29
    public static boolean sIsCancel;
Make this "public static sIsCancel" field final     NEW     squid:S1444  
"public static" fields should be constant
Move this variable to comply with Java Code Conventions.     NEW     squid:S1213  
The members of an interface declaration or class should appear in a pre-defined order
Make sIsCancel a static final constant or non-public and provide accessors if needed.     NEW     squid:ClassVariableVisibilityCheck  
Class variable fields should not have public accessibility
30

                  
31
    /**
35
     * @param text    文本
36
     */
37
    public static void showShortToastSafe(final Context context, final CharSequence text) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
38
        sHandler.post(new Runnable() {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Make this anonymous inner class a lambda (sonar.java.source not set. Assuming 8 or greater.)     NEW     squid:S1604  
Anonymous inner classes containing only one method should become lambdas
39
            @Override
40
            public void run() {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
41
                showToast(context, text, Toast.LENGTH_SHORT);
42
            }
50
     * @param resId   资源Id
51
     */
52
    public static void showShortToastSafe(final Context context, final int resId) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
53
        sHandler.post(new Runnable() {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Make this anonymous inner class a lambda (sonar.java.source not set. Assuming 8 or greater.)     NEW     squid:S1604  
Anonymous inner classes containing only one method should become lambdas
54
            @Override
55
            public void run() {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
56
                showToast(context, resId, Toast.LENGTH_SHORT);
57
            }
66
     * @param args    参数
67
     */
68
    public static void showShortToastSafe(final Context context, final int resId, final Object... args) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Do not use varargs.     NEW     squid:S923  
Functions should not be defined with a variable number of arguments
69
        sHandler.post(new Runnable() {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Make this anonymous inner class a lambda (sonar.java.source not set. Assuming 8 or greater.)     NEW     squid:S1604  
Anonymous inner classes containing only one method should become lambdas
70
            @Override
71
            public void run() {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
72
                showToast(context, resId, Toast.LENGTH_SHORT, args);
73
            }
82
     * @param args    参数
83
     */
84
    public static void showShortToastSafe(final Context context, final String format, final Object... args) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Do not use varargs.     NEW     squid:S923  
Functions should not be defined with a variable number of arguments
85
        sHandler.post(new Runnable() {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Make this anonymous inner class a lambda (sonar.java.source not set. Assuming 8 or greater.)     NEW     squid:S1604  
Anonymous inner classes containing only one method should become lambdas
86
            @Override
87
            public void run() {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
88
                showToast(context, format, Toast.LENGTH_SHORT, args);
89
            }
97
     * @param text    文本
98
     */
99
    public static void showLongToastSafe(final Context context, final CharSequence text) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
100
        sHandler.post(new Runnable() {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Make this anonymous inner class a lambda (sonar.java.source not set. Assuming 8 or greater.)     NEW     squid:S1604  
Anonymous inner classes containing only one method should become lambdas
101
            @Override
102
            public void run() {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
103
                showToast(context, text, Toast.LENGTH_LONG);
104
            }
112
     * @param resId   资源Id
113
     */
114
    public static void showLongToastSafe(final Context context, final int resId) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
115
        sHandler.post(new Runnable() {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Make this anonymous inner class a lambda (sonar.java.source not set. Assuming 8 or greater.)     NEW     squid:S1604  
Anonymous inner classes containing only one method should become lambdas
116
            @Override
117
            public void run() {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
118
                showToast(context, resId, Toast.LENGTH_LONG);
119
            }
128
     * @param args    参数
129
     */
130
    public static void showLongToastSafe(final Context context, final int resId, final Object... args) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Do not use varargs.     NEW     squid:S923  
Functions should not be defined with a variable number of arguments
131
        sHandler.post(new Runnable() {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Make this anonymous inner class a lambda (sonar.java.source not set. Assuming 8 or greater.)     NEW     squid:S1604  
Anonymous inner classes containing only one method should become lambdas
132
            @Override
133
            public void run() {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
134
                showToast(context, resId, Toast.LENGTH_LONG, args);
135
            }
144
     * @param args    参数
145
     */
146
    public static void showLongToastSafe(final Context context, final String format, final Object... args) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Do not use varargs.     NEW     squid:S923  
Functions should not be defined with a variable number of arguments
147
        sHandler.post(new Runnable() {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Make this anonymous inner class a lambda (sonar.java.source not set. Assuming 8 or greater.)     NEW     squid:S1604  
Anonymous inner classes containing only one method should become lambdas
148
            @Override
149
            public void run() {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
150
                showToast(context, format, Toast.LENGTH_LONG, args);
151
            }
159
     * @param text    文本
160
     */
161
    public static void showShortToast(Context context, CharSequence text) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
162
        showToast(context, text, Toast.LENGTH_SHORT);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
163
    }
164

                  
169
     * @param resId   资源Id
170
     */
171
    public static void showShortToast(Context context, int resId) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
172
        showToast(context, resId, Toast.LENGTH_SHORT);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
173
    }
174

                  
180
     * @param args    参数
181
     */
182
    public static void showShortToast(Context context, int resId, Object... args) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Do not use varargs.     NEW     squid:S923  
Functions should not be defined with a variable number of arguments
183
        showToast(context, resId, Toast.LENGTH_SHORT, args);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
184
    }
185

                  
191
     * @param args    参数
192
     */
193
    public static void showShortToast(Context context, String format, Object... args) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Do not use varargs.     NEW     squid:S923  
Functions should not be defined with a variable number of arguments
194
        showToast(context, format, Toast.LENGTH_SHORT, args);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
195
    }
196

                  
201
     * @param text    文本
202
     */
203
    public static void showLongToast(Context context, CharSequence text) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
204
        showToast(context, text, Toast.LENGTH_LONG);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
205
    }
206

                  
211
     * @param resId   资源Id
212
     */
213
    public static void showLongToast(Context context, int resId) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
214
        showToast(context, resId, Toast.LENGTH_LONG);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
215
    }
216

                  
222
     * @param args    参数
223
     */
224
    public static void showLongToast(Context context, int resId, Object... args) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Do not use varargs.     NEW     squid:S923  
Functions should not be defined with a variable number of arguments
225
        showToast(context, resId, Toast.LENGTH_LONG, args);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
226
    }
227

                  
233
     * @param args    参数
234
     */
235
    public static void showLongToast(Context context, String format, Object... args) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Do not use varargs.     NEW     squid:S923  
Functions should not be defined with a variable number of arguments
236
        showToast(context, format, Toast.LENGTH_LONG, args);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
237
    }
238

                  
244
     * @param duration 显示时长
245
     */
246
    private static void showToast(Context context, CharSequence text, int duration) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
247
        if (sToast == null) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
248
            sToast = Toast.makeText(context, text, duration);
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Synchronize this lazy initialization of 'sToast'     NEW     squid:S2444  
Lazy initialization of "static" fields should be "synchronized"
249
        } else {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "else" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
250
            if (sIsCancel) sToast.cancel();
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
251
            sToast.setText(text);
252
        }
261
     * @param duration 显示时长
262
     */
263
    private static void showToast(Context context, int resId, int duration) {
Remove this unused private "showToast" method.     NEW     squid:UnusedPrivateMethod  
Unused "private" methods should be removed
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
264
        showToast(context, context.getResources().getText(resId).toString(), duration);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
265
    }
266

                  
273
     * @param args     参数
274
     */
275
    private static void showToast(Context context, int resId, int duration, Object... args) {
Remove this unused private "showToast" method.     NEW     squid:UnusedPrivateMethod  
Unused "private" methods should be removed
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Do not use varargs.     NEW     squid:S923  
Functions should not be defined with a variable number of arguments
276
        showToast(context, String.format(context.getResources().getString(resId), args), duration);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
277
    }
278

                  
285
     * @param args     参数
286
     */
287
    private static void showToast(Context context, String format, int duration, Object... args) {
Remove this unused private "showToast" method.     NEW     squid:UnusedPrivateMethod  
Unused "private" methods should be removed
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Do not use varargs.     NEW     squid:S923  
Functions should not be defined with a variable number of arguments
288
        showToast(context, String.format(format, args), duration);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
289
    }
290

                  
292
     * 取消吐司显示
293
     */
294
    public static void cancelToast() {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
295
        if (sToast != null) sToast.cancel();
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
296
    }
297
}
3
New issues
Add or update the header of this file.     NEW     squid:S1451
Copyright and license headers should be defined
1
package com.blankj.utilcode.utils;
2

                  
9
 * </pre>
10
 */
11
public class VibrationUtils {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Remove this empty class, write its code or make it an "interface".     NEW     squid:S2094  
Classes should not be empty
12
}
166
New issues
Add or update the header of this file.     NEW     squid:S1451
Copyright and license headers should be defined
Add a new line at the end of this file.     NEW     squid:S00113
Files should contain an empty new line at the end
1
package com.blankj.utilcode.utils;
2

                  
27
 * </pre>
28
 */
29
public class ZipUtils {
Make this class "final" or add a public constructor.     NEW     squid:S2974  
Classes without "public" constructors should be "final"
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
30

                  
31
    private ZipUtils() {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Make this line start at column 3.     NEW     squid:IndentationCheck  
Source code should be indented consistently
32
        throw new UnsupportedOperationException("u can't instantiate me...");
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
33
    }
34

                  
42
     */
43
    public static boolean zipFiles(Collection<File> resFiles, String zipFilePath)
44
            throws IOException {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
45
        return zipFiles(resFiles, zipFilePath, null);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
46
    }
47

                  
56
     */
57
    public static boolean zipFiles(Collection<File> resFiles, String zipFilePath, String comment)
58
            throws IOException {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
59
        return zipFiles(resFiles, FileUtils.getFileByPath(zipFilePath), comment);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
60
    }
61

                  
69
     */
70
    public static boolean zipFiles(Collection<File> resFiles, File zipFile)
71
            throws IOException {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
72
        return zipFiles(resFiles, zipFile, null);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
73
    }
74

                  
83
     */
84
    public static boolean zipFiles(Collection<File> resFiles, File zipFile, String comment)
85
            throws IOException {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
86
        if (resFiles == null || zipFile == null) return false;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
87
        ZipOutputStream zos = null;
88
        try {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Change this "try" to a try-with-resources. (sonar.java.source not set. Assuming 7 or greater.)     NEW     squid:S2093  
Try-with-resources should be used
89
            zos = new ZipOutputStream(new FileOutputStream(zipFile));
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Close this "FileOutputStream".     NEW     squid:S2095  
Resources should be closed
90
            for (File resFile : resFiles) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
91
                if (!zipFile(resFile, "", zos, comment)) return false;
Make this line start at column 9.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
92
            }
93
            return true;
94
        } finally {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "finally" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
95
            if (zos != null) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
96
                zos.finish();
Make this line start at column 9.     NEW     squid:IndentationCheck  
Source code should be indented consistently
97
                FileUtils.closeIO(zos);
98
            }
109
     */
110
    public static boolean zipFile(String resFilePath, String zipFilePath)
111
            throws IOException {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
112
        return zipFile(resFilePath, zipFilePath, null);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
113
    }
114

                  
123
     */
124
    public static boolean zipFile(String resFilePath, String zipFilePath, String comment)
125
            throws IOException {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
126
        return zipFile(FileUtils.getFileByPath(resFilePath), FileUtils.getFileByPath(zipFilePath), comment);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
127
    }
128

                  
136
     */
137
    public static boolean zipFile(File resFile, File zipFile)
138
            throws IOException {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
139
        return zipFile(resFile, zipFile, null);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
140
    }
141

                  
150
     */
151
    public static boolean zipFile(File resFile, File zipFile, String comment)
152
            throws IOException {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
153
        if (resFile == null || zipFile == null) return false;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
154
        ZipOutputStream zos = null;
155
        try {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Change this "try" to a try-with-resources. (sonar.java.source not set. Assuming 7 or greater.)     NEW     squid:S2093  
Try-with-resources should be used
156
            zos = new ZipOutputStream(new FileOutputStream(zipFile));
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Close this "FileOutputStream".     NEW     squid:S2095  
Resources should be closed
157
            return zipFile(resFile, "", zos, comment);
158
        } finally {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "finally" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
159
            if (zos != null) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
160
                FileUtils.closeIO(zos);
Make this line start at column 9.     NEW     squid:IndentationCheck  
Source code should be indented consistently
161
            }
162
        }
173
     * @throws IOException IO错误时抛出
174
     */
175
    private static boolean zipFile(File resFile, String rootPath, ZipOutputStream zos, String comment)
The Cyclomatic Complexity of this method "zipFile" is 11 which is greater than 10 authorized.     NEW     squid:MethodCyclomaticComplexity  
Methods should not be too complex
176
            throws IOException {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
177
        rootPath = rootPath + (StringUtils.isSpace(rootPath) ? "" : File.separator) + resFile.getName();
Convert this usage of the ternary operator to an "if"/"else" structure.     NEW     squid:S1774  
The ternary operator should not be used
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Introduce a new variable instead of reusing the parameter "rootPath".     NEW     squid:S1226  
Method parameters, caught exceptions and foreach variables should not be reassigned
178
        if (resFile.isDirectory()) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
179
            File[] fileList = resFile.listFiles();
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
180
            // 如果是空文件夹那么创建它,我把'/'换为File.separator测试就不成功,eggPain
181
            if (fileList == null || fileList.length <= 0) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
182
                ZipEntry entry = new ZipEntry(rootPath + '/');
Make this line start at column 9.     NEW     squid:IndentationCheck  
Source code should be indented consistently
183
                if (!StringUtils.isEmpty(comment)) entry.setComment(comment);
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
184
                zos.putNextEntry(entry);
185
                zos.closeEntry();
186
            } else {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "else" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
187
                for (File file : fileList) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Make this line start at column 9.     NEW     squid:IndentationCheck  
Source code should be indented consistently
188
                    // 如果递归返回false则返回false
189
                    if (!zipFile(file, rootPath, zos, comment)) return false;
Make this line start at column 11.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Refactor this code to not nest more than 3 if/for/while/switch/try statements.     NEW     squid:S134  
Control flow statements "if", "for", "while", "switch" and "try" should not be nested too deeply
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
190
                }
191
            }
192
        } else {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "else" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
193
            InputStream is = null;
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
194
            try {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Change this "try" to a try-with-resources. (sonar.java.source not set. Assuming 7 or greater.)     NEW     squid:S2093  
Try-with-resources should be used
195
                is = new BufferedInputStream(new FileInputStream(resFile));
Make this line start at column 9.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Close this "FileInputStream".     NEW     squid:S2095  
Resources should be closed
196
                ZipEntry entry = new ZipEntry(rootPath);
197
                if (!StringUtils.isEmpty(comment)) entry.setComment(comment);
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
198
                zos.putNextEntry(entry);
199
                byte buffer[] = new byte[KB];
Move the array designator from the variable to the type.     NEW     squid:S1197  
Array designators "[]" should be on the type, not the variable
200
                int len;
201
                while ((len = is.read(buffer, 0, KB)) != -1) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
202
                    zos.write(buffer, 0, len);
Make this line start at column 11.     NEW     squid:IndentationCheck  
Source code should be indented consistently
203
                }
204
                zos.closeEntry();
205
            } finally {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "finally" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
206
                FileUtils.closeIO(is);
Make this line start at column 9.     NEW     squid:IndentationCheck  
Source code should be indented consistently
207
            }
208
        }
219
     */
220
    public static boolean unzipFiles(Collection<File> zipFiles, String destDirPath)
221
            throws IOException {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
222
        return unzipFiles(zipFiles, FileUtils.getFileByPath(destDirPath));
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
223
    }
224

                  
232
     */
233
    public static boolean unzipFiles(Collection<File> zipFiles, File destDir)
234
            throws IOException {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
235
        if (zipFiles == null || destDir == null) return false;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
236
        for (File zipFile : zipFiles) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
237
            if (!unzipFile(zipFile, destDir)) return false;
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
238
        }
239
        return true;
249
     */
250
    public static boolean unzipFile(String zipFilePath, String destDirPath)
251
            throws IOException {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
252
        return unzipFile(FileUtils.getFileByPath(zipFilePath), FileUtils.getFileByPath(destDirPath));
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
253
    }
254

                  
262
     */
263
    public static boolean unzipFile(File zipFile, File destDir)
264
            throws IOException {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
265
        return unzipFileByKeyword(zipFile, destDir, null) != null;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
266
    }
267

                  
276
     */
277
    public static List<File> unzipFileByKeyword(String zipFilePath, String destDirPath, String keyword)
278
            throws IOException {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
279
        return unzipFileByKeyword(FileUtils.getFileByPath(zipFilePath),
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
280
                FileUtils.getFileByPath(destDirPath), keyword);
281
    }
290
     * @throws IOException IO错误时抛出
291
     */
292
    public static List<File> unzipFileByKeyword(File zipFile, File destDir, String keyword)
Reduce the number of returns of this method 4, down to the maximum allowed 3.     NEW     squid:S1142  
Methods should not have too many return statements
The Cyclomatic Complexity of this method "unzipFileByKeyword" is 13 which is greater than 10 authorized.     NEW     squid:MethodCyclomaticComplexity  
Methods should not be too complex
293
            throws IOException {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
294
        if (zipFile == null || destDir == null) return null;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Return an empty collection instead of null.     NEW     squid:S1168  
Empty arrays and collections should be returned instead of null
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
295
        List<File> files = new ArrayList<>();
296
        ZipFile zf = new ZipFile(zipFile);
Close this "ZipFile".     NEW     squid:S2095  
Resources should be closed
297
        Enumeration<?> entries = zf.entries();
298
        while (entries.hasMoreElements()) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
299
            ZipEntry entry = ((ZipEntry) entries.nextElement());
Remove those useless parentheses.     NEW     squid:UselessParenthesesCheck  
Useless parentheses around expressions should be removed to prevent any misunderstanding
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
300
            String entryName = entry.getName();
301
            if (StringUtils.isEmpty(keyword) || FileUtils.getFileName(entryName).toLowerCase().contains(keyword.toLowerCase())) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Define the locale to be used in this String operation.     NEW     squid:S1449  
Locale should be used in String operations
Split this 129 characters long line (which is greater than 120 authorized).     NEW     squid:S00103  
Lines should not be too long
302
                String filePath = destDir + File.separator + entryName;
Make this line start at column 9.     NEW     squid:IndentationCheck  
Source code should be indented consistently
303
                File file = new File(filePath);
304
                files.add(file);
305
                if (entry.isDirectory()) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
306
                    if (!FileUtils.createOrExistsDir(file)) return null;
Make this line start at column 11.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Refactor this code to not nest more than 3 if/for/while/switch/try statements.     NEW     squid:S134  
Control flow statements "if", "for", "while", "switch" and "try" should not be nested too deeply
Return an empty collection instead of null.     NEW     squid:S1168  
Empty arrays and collections should be returned instead of null
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
307
                } else {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "else" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
308
                    if (!FileUtils.createOrExistsFile(file)) return null;
Make this line start at column 11.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Refactor this code to not nest more than 3 if/for/while/switch/try statements.     NEW     squid:S134  
Control flow statements "if", "for", "while", "switch" and "try" should not be nested too deeply
Return an empty collection instead of null.     NEW     squid:S1168  
Empty arrays and collections should be returned instead of null
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
309
                    InputStream in = null;
310
                    OutputStream out = null;
311
                    try {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Change this "try" to a try-with-resources. (sonar.java.source not set. Assuming 7 or greater.)     NEW     squid:S2093  
Try-with-resources should be used
Refactor this code to not nest more than 3 if/for/while/switch/try statements.     NEW     squid:S134  
Control flow statements "if", "for", "while", "switch" and "try" should not be nested too deeply
312
                        in = new BufferedInputStream(zf.getInputStream(entry));
Make this line start at column 13.     NEW     squid:IndentationCheck  
Source code should be indented consistently
313
                        out = new BufferedOutputStream(new FileOutputStream(file));
Close this "FileOutputStream".     NEW     squid:S2095  
Resources should be closed
314
                        byte buffer[] = new byte[KB];
Move the array designator from the variable to the type.     NEW     squid:S1197  
Array designators "[]" should be on the type, not the variable
315
                        int len;
316
                        while ((len = in.read(buffer)) != -1) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
317
                            out.write(buffer, 0, len);
Make this line start at column 15.     NEW     squid:IndentationCheck  
Source code should be indented consistently
318
                        }
319
                    } finally {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Move this "finally" keyword to a new dedicated line.     NEW     squid:RightCurlyBraceDifferentLineAsNextBlockCheck  
Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines
320
                        FileUtils.closeIO(in, out);
Make this line start at column 13.     NEW     squid:IndentationCheck  
Source code should be indented consistently
321
                    }
322
                }
334
     */
335
    public static List<String> getFilesPath(String zipFilePath)
336
            throws IOException {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
337
        return getFilesPath(FileUtils.getFileByPath(zipFilePath));
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
338
    }
339

                  
346
     */
347
    public static List<String> getFilesPath(File zipFile)
348
            throws IOException {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
349
        if (zipFile == null) return null;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Return an empty collection instead of null.     NEW     squid:S1168  
Empty arrays and collections should be returned instead of null
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
350
        List<String> paths = new ArrayList<>();
351
        Enumeration<?> entries = getEntries(zipFile);
352
        while (entries.hasMoreElements()) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
353
            paths.add(((ZipEntry) entries.nextElement()).getName());
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
354
        }
355
        return paths;
364
     */
365
    public static List<String> getComments(String zipFilePath)
366
            throws IOException {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
367
        return getComments(FileUtils.getFileByPath(zipFilePath));
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
368
    }
369

                  
376
     */
377
    public static List<String> getComments(File zipFile)
378
            throws IOException {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
379
        if (zipFile == null) return null;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Return an empty collection instead of null.     NEW     squid:S1168  
Empty arrays and collections should be returned instead of null
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
380
        List<String> comments = new ArrayList<>();
381
        Enumeration<?> entries = getEntries(zipFile);
382
        while (entries.hasMoreElements()) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
383
            ZipEntry entry = ((ZipEntry) entries.nextElement());
Remove those useless parentheses.     NEW     squid:UselessParenthesesCheck  
Useless parentheses around expressions should be removed to prevent any misunderstanding
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
384
            comments.add(entry.getComment());
385
        }
394
     * @throws IOException IO错误时抛出
395
     */
396
    public static Enumeration<?> getEntries(String zipFilePath)
Remove usage of generic wildcard type.     NEW     squid:S1452  
Generic wildcard types should not be used in return parameters
397
            throws IOException {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
398
        return getEntries(FileUtils.getFileByPath(zipFilePath));
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
399
    }
400

                  
406
     * @throws IOException IO错误时抛出
407
     */
408
    public static Enumeration<?> getEntries(File zipFile)
Remove usage of generic wildcard type.     NEW     squid:S1452  
Generic wildcard types should not be used in return parameters
409
            throws IOException {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
410
        if (zipFile == null) return null;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Missing curly brace.     NEW     squid:S00121  
Control structures should use curly braces
At most one statement is allowed per line, but 2 statements were found on this line.     NEW     squid:S00122  
Statements should be on separate lines
411
        return new ZipFile(zipFile).entries();
Close this "ZipFile".     NEW     squid:S2095  
Resources should be closed
412
    }
413
}
1
New issues
Add a 'package-info.java' file to document the 'utils' package     NEW     squid:S1228
Packages should have a javadoc file 'package-info.java'
23
New issues
Add or update the header of this file.     NEW     squid:S1451
Copyright and license headers should be defined
Add a new line at the end of this file.     NEW     squid:S00113
Files should contain an empty new line at the end
1
package com.blankj.utilcode.utils;
2

                  
3
import android.content.ContentResolver;
Remove this unused import 'android.content.ContentResolver'.     NEW     squid:UselessImportCheck  
Useless imports should be removed
4
import android.net.Uri;
5

                  
8
import org.robolectric.RobolectricTestRunner;
9
import org.robolectric.annotation.Config;
10
import org.robolectric.shadows.ShadowContentResolver;
Remove this unused import 'org.robolectric.shadows.ShadowContentResolver'.     NEW     squid:UselessImportCheck  
Useless imports should be removed
11

                  
12
import java.io.File;
Remove this unused import 'java.io.File'.     NEW     squid:UselessImportCheck  
Useless imports should be removed
13

                  
14
import static com.google.common.truth.Truth.assertThat;
24
@RunWith(RobolectricTestRunner.class)
25
@Config(manifest = Config.NONE)
26
public class ClipboardUtilsTest {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
27
    @Test
28
    public void testText() throws Exception {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Make this line start at column 3.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Document this public method.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
Define and throw a dedicated exception instead of using a generic one.     NEW     squid:S00112  
Generic exceptions should never be thrown
29
        ClipboardUtils.copyText(TestUtils.getContext(), "test");
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
30
        assertThat(ClipboardUtils.getText(TestUtils.getContext())).isEqualTo("test");
31
    }
32

                  
33
    @Test
34
    public void testUri() throws Exception {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document this public method.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
Define and throw a dedicated exception instead of using a generic one.     NEW     squid:S00112  
Generic exceptions should never be thrown
35
        ClipboardUtils.copyUri(TestUtils.getContext(), Uri.parse("http://www.blankj.com"));
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
36
        System.out.println((ClipboardUtils.getUri(TestUtils.getContext())));
Remove those useless parentheses.     NEW     squid:UselessParenthesesCheck  
Useless parentheses around expressions should be removed to prevent any misunderstanding
Replace this usage of System.out or System.err by a logger.     NEW     squid:S106  
Standard outputs should not be used directly to log anything
37
    }
38

                  
39
    @Test
40
    public void testIntent() throws Exception {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document this public method.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
Define and throw a dedicated exception instead of using a generic one.     NEW     squid:S00112  
Generic exceptions should never be thrown
41
//        ClipboardUtils.copyIntent(TestUtils.getContext(), IntentUtils.getShareTextIntent("test"));
This block of commented-out lines of code should be removed.     NEW     squid:CommentedOutCodeLine  
Sections of code should not be "commented out"
42
//        System.out.println(ClipboardUtils.getText(TestUtils.getContext()));
43
        System.out.println(NetworkUtils.getIpAddress("blankjv.com"));
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Replace this usage of System.out or System.err by a logger.     NEW     squid:S106  
Standard outputs should not be used directly to log anything
44
    }
45
}
53
New issues
Add or update the header of this file.     NEW     squid:S1451
Copyright and license headers should be defined
Add a new line at the end of this file.     NEW     squid:S00113
Files should contain an empty new line at the end
1
package com.blankj.utilcode.utils;
2

                  
16
 * </pre>
17
 */
18
public class ConvertUtilsTest {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
19

                  
20
    byte[] mBytes = new byte[]{0x00, 0x08, (byte) 0xdb, 0x33, 0x45, (byte) 0xab, 0x02, 0x23};
Explicitly declare the visibility for "mBytes".     NEW     squid:S2039  
Member variable visibility should be specified
Make this line start at column 3.     NEW     squid:IndentationCheck  
Source code should be indented consistently
21
    String hexString = "0008DB3345AB0223";
Explicitly declare the visibility for "hexString".     NEW     squid:S2039  
Member variable visibility should be specified
22

                  
23
    @Test
24
    public void testBytes2HexString() throws Exception {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document this public method.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
Define and throw a dedicated exception instead of using a generic one.     NEW     squid:S00112  
Generic exceptions should never be thrown
25
        assertThat(bytes2HexString(mBytes)).isEqualTo(hexString);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
26
    }
27

                  
28
    @Test
29
    public void testHexString2Bytes() throws Exception {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document this public method.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
Define and throw a dedicated exception instead of using a generic one.     NEW     squid:S00112  
Generic exceptions should never be thrown
30
        assertThat(hexString2Bytes(hexString)).isEqualTo(mBytes);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
31
    }
32

                  
33
    char[] mChars1 = new char[]{'0', '1', '2'};
Explicitly declare the visibility for "mChars1".     NEW     squid:S2039  
Member variable visibility should be specified
Move this variable to comply with Java Code Conventions.     NEW     squid:S1213  
The members of an interface declaration or class should appear in a pre-defined order
34
    byte[] mBytes1 = new byte[]{48, 49, 50};
Explicitly declare the visibility for "mBytes1".     NEW     squid:S2039  
Member variable visibility should be specified
Move this variable to comply with Java Code Conventions.     NEW     squid:S1213  
The members of an interface declaration or class should appear in a pre-defined order
Assign this magic number 48 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 49 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 50 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
35

                  
36
    @Test
37
    public void testChars2Bytes() throws Exception {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document this public method.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
Define and throw a dedicated exception instead of using a generic one.     NEW     squid:S00112  
Generic exceptions should never be thrown
38
        assertThat(chars2Bytes(mChars1)).isEqualTo(mBytes1);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
39
    }
40

                  
41
    @Test
42
    public void testBytes2Chars() throws Exception {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document this public method.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
Define and throw a dedicated exception instead of using a generic one.     NEW     squid:S00112  
Generic exceptions should never be thrown
43
        assertThat(bytes2Chars(mBytes1)).isEqualTo(mChars1);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
44
    }
45

                  
46
    @Test
47
    public void testByte2Unit() throws Exception {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document this public method.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
Define and throw a dedicated exception instead of using a generic one.     NEW     squid:S00112  
Generic exceptions should never be thrown
48
        assertThat(byte2Size(ConstUtils.GB, ConstUtils.MemoryUnit.MB) - 1024).isWithin(0.001);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Assign this magic number 1024 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 0.001 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
49
    }
50

                  
51
    @Test
52
    public void testByte2FitSize() throws Exception {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document this public method.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
Define and throw a dedicated exception instead of using a generic one.     NEW     squid:S00112  
Generic exceptions should never be thrown
53
        assertThat(byte2FitSize(1024 * 1024 * 3 + 1024 * 100)).isEqualTo("3.098MB");
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Assign this magic number 1024 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 1024 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 3 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 1024 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 100 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
54
    }
55

                  
56
    @Test
57
    public void testInputStream2BytesAndBytes2InputStream() throws Exception {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document this public method.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
Define and throw a dedicated exception instead of using a generic one.     NEW     squid:S00112  
Generic exceptions should never be thrown
58
        String string = "this is test string";
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
59
        assertThat(new String(inputStream2Bytes(
60
                bytes2InputStream(string.getBytes("UTF-8")))))
Define a constant instead of duplicating this literal "UTF-8" 3 times.     NEW     squid:S1192  
String literals should not be duplicated
61
                .isEqualTo(string);
62
    }
63

                  
64
    @Test
65
    public void testInputStream2StringAndString2InputStream() throws Exception {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document this public method.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
Define and throw a dedicated exception instead of using a generic one.     NEW     squid:S00112  
Generic exceptions should never be thrown
66
        String string = "this is test string";
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
67
        assertThat(inputStream2String(
68
                string2InputStream(string, "UTF-8")
7
New issues
Add or update the header of this file.     NEW     squid:S1451
Copyright and license headers should be defined
Add a new line at the end of this file.     NEW     squid:S00113
Files should contain an empty new line at the end
1
package com.blankj.utilcode.utils;
2

                  
28
@RunWith(RobolectricTestRunner.class)
29
@Config(manifest = Config.NONE , sdk = 23)
30
public class EmptyUtilsTest {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
31

                  
32
    @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
33
    @Test
34
    public void isEmpty() throws Exception {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Make this line start at column 3.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Define and throw a dedicated exception instead of using a generic one.     NEW     squid:S00112  
Generic exceptions should never be thrown
35
        String string = "";
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
36
        String string1 = " ";
37
        int[][] arr = new int[][]{};
35
New issues
Add or update the header of this file.     NEW     squid:S1451
Copyright and license headers should be defined
Add a new line at the end of this file.     NEW     squid:S00113
Files should contain an empty new line at the end
1
package com.blankj.utilcode.utils;
2

                  
19
@RunWith(RobolectricTestRunner.class)
20
@Config(manifest = Config.NONE)
21
public class EncodeUtilsTest {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
22

                  
23
    String urlEncodeString = "%E5%93%88%E5%93%88%E5%93%88";
Explicitly declare the visibility for "urlEncodeString".     NEW     squid:S2039  
Member variable visibility should be specified
Make this line start at column 3.     NEW     squid:IndentationCheck  
Source code should be indented consistently
24
    String html = "<html>" +
Explicitly declare the visibility for "html".     NEW     squid:S2039  
Member variable visibility should be specified
25
            "<head>" +
26
            "<title>我的第一个 HTML 页面</title>" +
31
            "</body>" +
32
            "</html>";
33
    String encodeHtml = "&lt;html&gt;&lt;head&gt;&lt;title&gt;&#25105;&#30340;&#31532;&#19968;&#20010; HTML &#39029;&#38754;&lt;/title&gt;&lt;/head&gt;&lt;body&gt;&lt;p&gt;body &#20803;&#32032;&#30340;&#20869;&#23481;&#20250;&#26174;&#31034;&#22312;&#27983;&#35272;&#22120;&#20013;&#12290;&lt;/p&gt;&lt;p&gt;title &#20803;&#32032;&#30340;&#20869;&#23481;&#20250;&#26174;&#31034;&#22312;&#27983;&#35272;&#22120;&#30340;&#26631;&#39064;&#26639;&#20013;&#12290;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;";
Explicitly declare the visibility for "encodeHtml".     NEW     squid:S2039  
Member variable visibility should be specified
Split this 496 characters long line (which is greater than 120 authorized).     NEW     squid:S00103  
Lines should not be too long
34

                  
35
    @Test
36
    public void testUrlEncode() throws Exception {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document this public method.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
Define and throw a dedicated exception instead of using a generic one.     NEW     squid:S00112  
Generic exceptions should never be thrown
37
        assertThat(urlEncode("哈哈哈")).isEqualTo(urlEncodeString);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
38
        assertThat(urlEncode("哈哈哈", "UTF-8")).isEqualTo(urlEncodeString);
39
    }
40

                  
41
    @Test
42
    public void testUrlDecode() throws Exception {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document this public method.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
Define and throw a dedicated exception instead of using a generic one.     NEW     squid:S00112  
Generic exceptions should never be thrown
43
        assertThat(urlDecode(urlEncodeString)).isEqualTo("哈哈哈");
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
44
        assertThat(urlDecode(urlEncodeString, "UTF-8")).isEqualTo("哈哈哈");
45
    }
46

                  
47
    @Test
48
    public void testBase64EncodeAndDecode() throws Exception {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document this public method.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
Define and throw a dedicated exception instead of using a generic one.     NEW     squid:S00112  
Generic exceptions should never be thrown
49
        assertThat(base64Decode(base64Encode("blankj")))
Define a constant instead of duplicating this literal "blankj" 6 times.     NEW     squid:S1192  
String literals should not be duplicated
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
50
                .isEqualTo("blankj".getBytes());
Remove this use of "getBytes"     NEW     squid:S1943  
Classes and methods that rely on the default system encoding should not be used
51
        assertThat(base64Decode(base64Encode2String("blankj".getBytes())))
Remove this use of "getBytes"     NEW     squid:S1943  
Classes and methods that rely on the default system encoding should not be used
52
                .isEqualTo("blankj".getBytes());
Remove this use of "getBytes"     NEW     squid:S1943  
Classes and methods that rely on the default system encoding should not be used
53
        assertThat(base64Encode2String("blankj".getBytes()))
Remove this use of "getBytes"     NEW     squid:S1943  
Classes and methods that rely on the default system encoding should not be used
54
                .isEqualTo("Ymxhbmtq");
55
        assertThat(base64Encode("blankj".getBytes()))
Remove this use of "getBytes"     NEW     squid:S1943  
Classes and methods that rely on the default system encoding should not be used
56
                .isEqualTo("Ymxhbmtq".getBytes());
Remove this use of "getBytes"     NEW     squid:S1943  
Classes and methods that rely on the default system encoding should not be used
57
    }
58

                  
59
    @Test
60
    public void testHtmlEncode() throws Exception {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document this public method.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
Define and throw a dedicated exception instead of using a generic one.     NEW     squid:S00112  
Generic exceptions should never be thrown
61
        assertThat(htmlEncode(html)).isEqualTo(encodeHtml);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
62
    }
63

                  
64
    @Test
65
    public void testHtmlDecode() throws Exception {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document this public method.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
Define and throw a dedicated exception instead of using a generic one.     NEW     squid:S00112  
Generic exceptions should never be thrown
66
        assertThat(htmlDecode(encodeHtml)).isEqualTo(html);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
67
    }
68
}
123
New issues
Add or update the header of this file.     NEW     squid:S1451
Copyright and license headers should be defined
Add a new line at the end of this file.     NEW     squid:S00113
Files should contain an empty new line at the end
1
package com.blankj.utilcode.utils;
2

                  
23
@RunWith(RobolectricTestRunner.class)
24
@Config(manifest = Config.NONE)
25
public class EncryptUtilsTest {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
26

                  
27
    String blankjMD2 = "15435017570D8A73449E25C4622E17A4";
Explicitly declare the visibility for "blankjMD2".     NEW     squid:S2039  
Member variable visibility should be specified
Make this line start at column 3.     NEW     squid:IndentationCheck  
Source code should be indented consistently
28
    String blankjMD5 = "AAC25CD336E01C8655F4EC7875445A60";
Explicitly declare the visibility for "blankjMD5".     NEW     squid:S2039  
Member variable visibility should be specified
29
    String blankjSHA1 = "C606ACCB1FEB669E19D080ADDDDBB8E6CDA5F43C";
Explicitly declare the visibility for "blankjSHA1".     NEW     squid:S2039  
Member variable visibility should be specified
30
    String blankjSHA224 = "F4C5C0E8CF56CAC4D06DB6B523F67621859A9D79BDA4B2AC03097D5F";
Explicitly declare the visibility for "blankjSHA224".     NEW     squid:S2039  
Member variable visibility should be specified
31
    String blankjSHA256 = "8BD80AE90DFBA112786367BEBDDEE60A638EF5B82682EDF8F3D3CA8E6BFEF648";
Explicitly declare the visibility for "blankjSHA256".     NEW     squid:S2039  
Member variable visibility should be specified
32
    String blankjSHA384 =
Explicitly declare the visibility for "blankjSHA384".     NEW     squid:S2039  
Member variable visibility should be specified
33
            "BF831E5221FC108D6A72ACB888BA3EB0C030A5F01BA2F739856BE70681D86F992B85E0D461101C74BAEDA895BD422557";
34
    String blankjSHA512 =
Explicitly declare the visibility for "blankjSHA512".     NEW     squid:S2039  
Member variable visibility should be specified
35
            "D59D31067F614ED3586F85A31FEFDB7F33096316DA26EBE0FF440B241C8560D96650F100D78C512560C976949EFA89CB5D5589DCF68C7FAADE98F03BCFEC2B45";
Split this 143 characters long line (which is greater than 120 authorized).     NEW     squid:S00103  
Lines should not be too long
36

                  
37
    @Test
38
    public void testEncryptMD2() throws Exception {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document this public method.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
Define and throw a dedicated exception instead of using a generic one.     NEW     squid:S00112  
Generic exceptions should never be thrown
39
        assertThat(encryptMD2ToString("blankj")).isEqualTo(blankjMD2);
Define a constant instead of duplicating this literal "blankj" 21 times.     NEW     squid:S1192  
String literals should not be duplicated
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
40
        assertThat(encryptMD2ToString("blankj".getBytes())).isEqualTo(blankjMD2);
Remove this use of "getBytes"     NEW     squid:S1943  
Classes and methods that rely on the default system encoding should not be used
41
        assertThat(encryptMD2("blankj".getBytes())).isEqualTo(hexString2Bytes(blankjMD2));
Remove this use of "getBytes"     NEW     squid:S1943  
Classes and methods that rely on the default system encoding should not be used
42
    }
43

                  
44
    @Test
45
    public void testEncryptMD5() throws Exception {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document this public method.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
Define and throw a dedicated exception instead of using a generic one.     NEW     squid:S00112  
Generic exceptions should never be thrown
46
        assertThat(encryptMD5ToString("blankj")).isEqualTo(blankjMD5);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
47
        assertThat(encryptMD5ToString("blankj".getBytes())).isEqualTo(blankjMD5);
Remove this use of "getBytes"     NEW     squid:S1943  
Classes and methods that rely on the default system encoding should not be used
48
        assertThat(encryptMD5("blankj".getBytes())).isEqualTo(hexString2Bytes(blankjMD5));
Remove this use of "getBytes"     NEW     squid:S1943  
Classes and methods that rely on the default system encoding should not be used
49
    }
50

                  
51
    @Test
52
    public void testEncryptSHA1() throws Exception {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document this public method.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
Define and throw a dedicated exception instead of using a generic one.     NEW     squid:S00112  
Generic exceptions should never be thrown
53
        assertThat(encryptSHA1ToString("blankj")).isEqualTo(blankjSHA1);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
54
        assertThat(encryptSHA1ToString("blankj".getBytes())).isEqualTo(blankjSHA1);
Remove this use of "getBytes"     NEW     squid:S1943  
Classes and methods that rely on the default system encoding should not be used
55
        assertThat(encryptSHA1("blankj".getBytes())).isEqualTo(hexString2Bytes(blankjSHA1));
Remove this use of "getBytes"     NEW     squid:S1943  
Classes and methods that rely on the default system encoding should not be used
56
    }
57

                  
58
    @Test
59
    public void testEncryptSHA224() throws Exception {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document this public method.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
Define and throw a dedicated exception instead of using a generic one.     NEW     squid:S00112  
Generic exceptions should never be thrown
60
        assertThat(encryptSHA224ToString("blankj")).isEqualTo(blankjSHA224);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
61
        assertThat(encryptSHA224ToString("blankj".getBytes())).isEqualTo(blankjSHA224);
Remove this use of "getBytes"     NEW     squid:S1943  
Classes and methods that rely on the default system encoding should not be used
62
        assertThat(encryptSHA224("blankj".getBytes())).isEqualTo(hexString2Bytes(blankjSHA224));
Remove this use of "getBytes"     NEW     squid:S1943  
Classes and methods that rely on the default system encoding should not be used
63
    }
64

                  
65
    @Test
66
    public void testEncryptSHA256() throws Exception {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document this public method.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
Define and throw a dedicated exception instead of using a generic one.     NEW     squid:S00112  
Generic exceptions should never be thrown
67
        assertThat(encryptSHA256ToString("blankj")).isEqualTo(blankjSHA256);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
68
        assertThat(encryptSHA256ToString("blankj".getBytes())).isEqualTo(blankjSHA256);
Remove this use of "getBytes"     NEW     squid:S1943  
Classes and methods that rely on the default system encoding should not be used
69
        assertThat(encryptSHA256("blankj".getBytes())).isEqualTo(hexString2Bytes(blankjSHA256));
Remove this use of "getBytes"     NEW     squid:S1943  
Classes and methods that rely on the default system encoding should not be used
70
    }
71

                  
72
    @Test
73
    public void testEncryptSHA384() throws Exception {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document this public method.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
Define and throw a dedicated exception instead of using a generic one.     NEW     squid:S00112  
Generic exceptions should never be thrown
74
        assertThat(encryptSHA384ToString("blankj")).isEqualTo(blankjSHA384);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
75
        assertThat(encryptSHA384ToString("blankj".getBytes())).isEqualTo(blankjSHA384);
Remove this use of "getBytes"     NEW     squid:S1943  
Classes and methods that rely on the default system encoding should not be used
76
        assertThat(encryptSHA384("blankj".getBytes())).isEqualTo(hexString2Bytes(blankjSHA384));
Remove this use of "getBytes"     NEW     squid:S1943  
Classes and methods that rely on the default system encoding should not be used
77
    }
78

                  
79
    @Test
80
    public void testEncryptSHA512() throws Exception {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document this public method.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
Define and throw a dedicated exception instead of using a generic one.     NEW     squid:S00112  
Generic exceptions should never be thrown
81
        assertThat(encryptSHA512ToString("blankj")).isEqualTo(blankjSHA512);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
82
        assertThat(encryptSHA512ToString("blankj".getBytes())).isEqualTo(blankjSHA512);
Remove this use of "getBytes"     NEW     squid:S1943  
Classes and methods that rely on the default system encoding should not be used
83
        assertThat(encryptSHA512("blankj".getBytes())).isEqualTo(hexString2Bytes(blankjSHA512));
Remove this use of "getBytes"     NEW     squid:S1943  
Classes and methods that rely on the default system encoding should not be used
84
    }
85

                  
86
    String dataDES = "0008DB3345AB0223";
Explicitly declare the visibility for "dataDES".     NEW     squid:S2039  
Member variable visibility should be specified
Move this variable to comply with Java Code Conventions.     NEW     squid:S1213  
The members of an interface declaration or class should appear in a pre-defined order
87
    String keyDES = "6801020304050607";
Explicitly declare the visibility for "keyDES".     NEW     squid:S2039  
Member variable visibility should be specified
Move this variable to comply with Java Code Conventions.     NEW     squid:S1213  
The members of an interface declaration or class should appear in a pre-defined order
88
    String resDES = "1F7962581118F360";
Explicitly declare the visibility for "resDES".     NEW     squid:S2039  
Member variable visibility should be specified
Move this variable to comply with Java Code Conventions.     NEW     squid:S1213  
The members of an interface declaration or class should appear in a pre-defined order
89
    byte[] bytesDataDES = hexString2Bytes(dataDES);
Explicitly declare the visibility for "bytesDataDES".     NEW     squid:S2039  
Member variable visibility should be specified
Move this variable to comply with Java Code Conventions.     NEW     squid:S1213  
The members of an interface declaration or class should appear in a pre-defined order
90
    byte[] bytesKeyDES = hexString2Bytes(keyDES);
Explicitly declare the visibility for "bytesKeyDES".     NEW     squid:S2039  
Member variable visibility should be specified
Move this variable to comply with Java Code Conventions.     NEW     squid:S1213  
The members of an interface declaration or class should appear in a pre-defined order
91
    byte[] bytesResDES = hexString2Bytes(resDES);
Explicitly declare the visibility for "bytesResDES".     NEW     squid:S2039  
Member variable visibility should be specified
Move this variable to comply with Java Code Conventions.     NEW     squid:S1213  
The members of an interface declaration or class should appear in a pre-defined order
92

                  
93
    @Test
94
    public void testEncryptDES() throws Exception {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document this public method.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
Define and throw a dedicated exception instead of using a generic one.     NEW     squid:S00112  
Generic exceptions should never be thrown
95
        assertThat(encryptDES(bytesDataDES, bytesKeyDES)).isEqualTo(bytesResDES);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
96
        assertThat(encryptDES2HexString(bytesDataDES, bytesKeyDES)).isEqualTo(resDES);
97
        assertThat(encryptDES2Base64(bytesDataDES, bytesKeyDES)).isEqualTo(base64Encode
100

                  
101
    @Test
102
    public void testDecryptDES() throws Exception {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document this public method.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
Define and throw a dedicated exception instead of using a generic one.     NEW     squid:S00112  
Generic exceptions should never be thrown
103
        assertThat(decryptDES(bytesResDES, bytesKeyDES)).isEqualTo(bytesDataDES);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
104
        assertThat(decryptHexStringDES(resDES, bytesKeyDES)).isEqualTo(bytesDataDES);
105
        assertThat(decryptBase64DES(base64Encode(bytesResDES), bytesKeyDES)).isEqualTo
107
    }
108

                  
109
    String data3DES = "1111111111111111";
Explicitly declare the visibility for "data3DES".     NEW     squid:S2039  
Member variable visibility should be specified
Move this variable to comply with Java Code Conventions.     NEW     squid:S1213  
The members of an interface declaration or class should appear in a pre-defined order
110
    String key3DES = "111111111111111111111111111111111111111111111111";
Explicitly declare the visibility for "key3DES".     NEW     squid:S2039  
Member variable visibility should be specified
Move this variable to comply with Java Code Conventions.     NEW     squid:S1213  
The members of an interface declaration or class should appear in a pre-defined order
111
    String res3DES = "F40379AB9E0EC533";
Explicitly declare the visibility for "res3DES".     NEW     squid:S2039  
Member variable visibility should be specified
Move this variable to comply with Java Code Conventions.     NEW     squid:S1213  
The members of an interface declaration or class should appear in a pre-defined order
112
    byte[] bytesDataDES3 = hexString2Bytes(data3DES);
Explicitly declare the visibility for "bytesDataDES3".     NEW     squid:S2039  
Member variable visibility should be specified
Move this variable to comply with Java Code Conventions.     NEW     squid:S1213  
The members of an interface declaration or class should appear in a pre-defined order
113
    byte[] bytesKeyDES3 = hexString2Bytes(key3DES);
Explicitly declare the visibility for "bytesKeyDES3".     NEW     squid:S2039  
Member variable visibility should be specified
Move this variable to comply with Java Code Conventions.     NEW     squid:S1213  
The members of an interface declaration or class should appear in a pre-defined order
114
    byte[] bytesResDES3 = hexString2Bytes(res3DES);
Explicitly declare the visibility for "bytesResDES3".     NEW     squid:S2039  
Member variable visibility should be specified
Move this variable to comply with Java Code Conventions.     NEW     squid:S1213  
The members of an interface declaration or class should appear in a pre-defined order
115

                  
116
    @Test
117
    public void testEncrypt3DES() throws Exception {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document this public method.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
Define and throw a dedicated exception instead of using a generic one.     NEW     squid:S00112  
Generic exceptions should never be thrown
118
        assertThat(encrypt3DES(bytesDataDES3, bytesKeyDES3)).isEqualTo(bytesResDES3);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
119
        assertThat(encrypt3DES2HexString(bytesDataDES3, bytesKeyDES3)).isEqualTo(res3DES);
120
        assertThat(encrypt3DES2Base64(bytesDataDES3, bytesKeyDES3)).isEqualTo(base64Encode
123

                  
124
    @Test
125
    public void testDecrypt3DES() throws Exception {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document this public method.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
Define and throw a dedicated exception instead of using a generic one.     NEW     squid:S00112  
Generic exceptions should never be thrown
126
        assertThat(decrypt3DES(bytesResDES3, bytesKeyDES3)).isEqualTo(bytesDataDES3);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
127
        assertThat(decryptHexString3DES(res3DES, bytesKeyDES3)).isEqualTo(bytesDataDES3);
128
        assertThat(decryptBase64_3DES(base64Encode(bytesResDES3), bytesKeyDES3)).isEqualTo
130
    }
131

                  
132
    String dataAES = "11111111111111111111111111111111";
Explicitly declare the visibility for "dataAES".     NEW     squid:S2039  
Member variable visibility should be specified
Move this variable to comply with Java Code Conventions.     NEW     squid:S1213  
The members of an interface declaration or class should appear in a pre-defined order
133
    String keyAES = "11111111111111111111111111111111";
Explicitly declare the visibility for "keyAES".     NEW     squid:S2039  
Member variable visibility should be specified
Move this variable to comply with Java Code Conventions.     NEW     squid:S1213  
The members of an interface declaration or class should appear in a pre-defined order
134
    String resAES = "E56E26F5608B8D268F2556E198A0E01B";
Explicitly declare the visibility for "resAES".     NEW     squid:S2039  
Member variable visibility should be specified
Move this variable to comply with Java Code Conventions.     NEW     squid:S1213  
The members of an interface declaration or class should appear in a pre-defined order
135
    byte[] bytesDataAES = hexString2Bytes(dataAES);
Explicitly declare the visibility for "bytesDataAES".     NEW     squid:S2039  
Member variable visibility should be specified
Move this variable to comply with Java Code Conventions.     NEW     squid:S1213  
The members of an interface declaration or class should appear in a pre-defined order
136
    byte[] bytesKeyAES = hexString2Bytes(keyAES);
Explicitly declare the visibility for "bytesKeyAES".     NEW     squid:S2039  
Member variable visibility should be specified
Move this variable to comply with Java Code Conventions.     NEW     squid:S1213  
The members of an interface declaration or class should appear in a pre-defined order
137
    byte[] bytesResAES = hexString2Bytes(resAES);
Explicitly declare the visibility for "bytesResAES".     NEW     squid:S2039  
Member variable visibility should be specified
Move this variable to comply with Java Code Conventions.     NEW     squid:S1213  
The members of an interface declaration or class should appear in a pre-defined order
138

                  
139
    @Test
140
    public void testEncryptAES() throws Exception {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document this public method.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
Define and throw a dedicated exception instead of using a generic one.     NEW     squid:S00112  
Generic exceptions should never be thrown
141
        assertThat(encryptAES(bytesDataAES, bytesKeyAES)).isEqualTo(bytesResAES);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
142
        assertThat(encryptAES2HexString(bytesDataAES, bytesKeyAES)).isEqualTo(resAES);
143
        assertThat(encryptAES2Base64(bytesDataAES, bytesKeyAES)).isEqualTo(base64Encode
146

                  
147
    @Test
148
    public void testDecryptAES() throws Exception {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document this public method.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
Define and throw a dedicated exception instead of using a generic one.     NEW     squid:S00112  
Generic exceptions should never be thrown
149
        assertThat(decryptAES(bytesResAES, bytesKeyAES)).isEqualTo(bytesDataAES);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
150
        assertThat(decryptHexStringAES(resAES, bytesKeyAES)).isEqualTo(bytesDataAES);
151
        assertThat(decryptBase64AES(base64Encode(bytesResAES), bytesKeyAES)).isEqualTo
153
    }
154

                  
155
    String path = TestUtils.BASEPATH + "encrypt" + TestUtils.SEP;
Explicitly declare the visibility for "path".     NEW     squid:S2039  
Member variable visibility should be specified
Move this variable to comply with Java Code Conventions.     NEW     squid:S1213  
The members of an interface declaration or class should appear in a pre-defined order
156
    String md5 = "7F138A09169B250E9DCB378140907378";
Explicitly declare the visibility for "md5".     NEW     squid:S2039  
Member variable visibility should be specified
Move this variable to comply with Java Code Conventions.     NEW     squid:S1213  
The members of an interface declaration or class should appear in a pre-defined order
157

                  
158
    @Test
159
    public void testEncryptMD5File() throws Exception {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document this public method.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
Define and throw a dedicated exception instead of using a generic one.     NEW     squid:S00112  
Generic exceptions should never be thrown
160
        assertThat(encryptMD5File2String(new File(path + "MD5.txt"))).isEqualTo(md5);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
161
    }
162
}
155
New issues
Add or update the header of this file.     NEW     squid:S1451
Copyright and license headers should be defined
Add a new line at the end of this file.     NEW     squid:S00113
Files should contain an empty new line at the end
1
package com.blankj.utilcode.utils;
2

                  
20
 * </pre>
21
 */
22
public class FileUtilsTest {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
23

                  
24

                  
25
    String path = BASEPATH + "file" + SEP;
Explicitly declare the visibility for "path".     NEW     squid:S2039  
Member variable visibility should be specified
Make this line start at column 3.     NEW     squid:IndentationCheck  
Source code should be indented consistently
26

                  
27
    @Test
28
    public void testGetFileByPath() throws Exception {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document this public method.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
Define and throw a dedicated exception instead of using a generic one.     NEW     squid:S00112  
Generic exceptions should never be thrown
29
        System.out.println(new byte[0].length);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Replace this usage of System.out or System.err by a logger.     NEW     squid:S106  
Standard outputs should not be used directly to log anything
30
        assertThat(getFileByPath(" ")).isNull();
31
        assertThat(getFileByPath("c:")).isNotNull();
33

                  
34
    @Test
35
    public void testIsFileExists() throws Exception {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document this public method.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
Define and throw a dedicated exception instead of using a generic one.     NEW     squid:S00112  
Generic exceptions should never be thrown
36
        assertThat(isFileExists(path + "UTF8.txt")).isTrue();
Define a constant instead of duplicating this literal "UTF8.txt" 26 times.     NEW     squid:S1192  
String literals should not be duplicated
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
37
        assertThat(isFileExists(path + "UTF8")).isFalse();
38
    }
39

                  
40
    @Test
41
    public void testIsDir() throws Exception {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document this public method.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
Define and throw a dedicated exception instead of using a generic one.     NEW     squid:S00112  
Generic exceptions should never be thrown
42
        assertThat(isDir(path + "UTF8.txt")).isFalse();
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
43
        assertThat(isDir(path)).isTrue();
44
    }
45

                  
46
    @Test
47
    public void testIsFile() throws Exception {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document this public method.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
Define and throw a dedicated exception instead of using a generic one.     NEW     squid:S00112  
Generic exceptions should never be thrown
48
        assertThat(isFile(path + "UTF8.txt")).isTrue();
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
49
        assertThat(isFile(path)).isFalse();
50
    }
51

                  
52
    @Test
53
    public void testCreateOrExistsDir() throws Exception {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document this public method.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
Define and throw a dedicated exception instead of using a generic one.     NEW     squid:S00112  
Generic exceptions should never be thrown
54
        assertThat(createOrExistsDir(path + "new Dir")).isTrue();
Define a constant instead of duplicating this literal "new Dir" 4 times.     NEW     squid:S1192  
String literals should not be duplicated
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
55
        assertThat(createOrExistsDir(path)).isTrue();
56
    }
57

                  
58
    @Test
59
    public void testCreateOrExistsFile() throws Exception {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document this public method.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
Define and throw a dedicated exception instead of using a generic one.     NEW     squid:S00112  
Generic exceptions should never be thrown
60
        assertThat(createOrExistsFile(path + "new File")).isTrue();
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
61
        assertThat(createOrExistsFile(path)).isFalse();
62
    }
63

                  
64
    @Test
65
    public void testCreateFileByDeleteOldFile() throws Exception {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document this public method.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
Define and throw a dedicated exception instead of using a generic one.     NEW     squid:S00112  
Generic exceptions should never be thrown
66
        assertThat(createFileByDeleteOldFile(path + "new File")).isTrue();
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
67
        assertThat(createFileByDeleteOldFile(path)).isFalse();
68
    }
69

                  
70
    String path1 = BASEPATH + "file1" + SEP;
Explicitly declare the visibility for "path1".     NEW     squid:S2039  
Member variable visibility should be specified
Move this variable to comply with Java Code Conventions.     NEW     squid:S1213  
The members of an interface declaration or class should appear in a pre-defined order
71

                  
72
    @Test
73
    public void testCopyDir() throws Exception {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document this public method.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
Define and throw a dedicated exception instead of using a generic one.     NEW     squid:S00112  
Generic exceptions should never be thrown
74
        assertThat(copyDir(path, path)).isFalse();
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
75
        assertThat(copyDir(path, path + "new Dir")).isFalse();
76
        assertThat(copyDir(path, path1)).isTrue();
78

                  
79
    @Test
80
    public void testCopyFile() throws Exception {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document this public method.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
Define and throw a dedicated exception instead of using a generic one.     NEW     squid:S00112  
Generic exceptions should never be thrown
81
        assertThat(copyFile(path + "GBK.txt", path + "GBK.txt")).isFalse();
Define a constant instead of duplicating this literal "GBK.txt" 15 times.     NEW     squid:S1192  
String literals should not be duplicated
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
82
        assertThat(copyFile(path + "GBK.txt", path + "new Dir" + SEP + "GBK.txt")).isTrue();
83
        assertThat(copyFile(path + "GBK.txt", path1 + "GBK.txt")).isTrue();
85

                  
86
    @Test
87
    public void testMoveDir() throws Exception {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document this public method.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
Define and throw a dedicated exception instead of using a generic one.     NEW     squid:S00112  
Generic exceptions should never be thrown
88
        assertThat(moveDir(path, path)).isFalse();
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
89
        assertThat(moveDir(path, path + "new Dir")).isFalse();
90
        assertThat(moveDir(path, path1)).isTrue();
93

                  
94
    @Test
95
    public void testMoveFile() throws Exception {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document this public method.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
Define and throw a dedicated exception instead of using a generic one.     NEW     squid:S00112  
Generic exceptions should never be thrown
96
        assertThat(moveFile(path + "GBK.txt", path + "GBK.txt")).isFalse();
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
97
        assertThat(moveFile(path + "GBK.txt", path1 + "GBK.txt")).isTrue();
98
        assertThat(moveFile(path1 + "GBK.txt", path + "GBK.txt")).isTrue();
100

                  
101
    @Test
102
    public void testDeleteDir() throws Exception {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document this public method.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
Define and throw a dedicated exception instead of using a generic one.     NEW     squid:S00112  
Generic exceptions should never be thrown
103
        assertThat(deleteDir(path + "GBK.txt")).isFalse();
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
104
        assertThat(deleteDir(path + "del")).isTrue();
105
    }
106

                  
107
    @Test
108
    public void testDeleteFile() throws Exception {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document this public method.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
Define and throw a dedicated exception instead of using a generic one.     NEW     squid:S00112  
Generic exceptions should never be thrown
109
        assertThat(deleteFile(path)).isFalse();
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
110
        assertThat(deleteFile(path + "GBK1.txt")).isTrue();
111
        assertThat(deleteFile(path + "del.txt")).isTrue();
113

                  
114
    @Test
115
    public void testDeleteFilesInDir() throws Exception {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document this public method.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
Define and throw a dedicated exception instead of using a generic one.     NEW     squid:S00112  
Generic exceptions should never be thrown
116
        assertThat(deleteFilesInDir(path + "child")).isTrue();
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
117
    }
118

                  
119
    @Test
120
    public void testListFilesInDir() throws Exception {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document this public method.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
Define and throw a dedicated exception instead of using a generic one.     NEW     squid:S00112  
Generic exceptions should never be thrown
121
        System.out.println(listFilesInDir(path, false).toString());
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Replace this usage of System.out or System.err by a logger.     NEW     squid:S106  
Standard outputs should not be used directly to log anything
122
        System.out.println(listFilesInDir(path, true).toString());
Replace this usage of System.out or System.err by a logger.     NEW     squid:S106  
Standard outputs should not be used directly to log anything
123
    }
124

                  
125
    FilenameFilter filter = new FilenameFilter() {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Explicitly declare the visibility for "filter".     NEW     squid:S2039  
Member variable visibility should be specified
Move this variable to comply with Java Code Conventions.     NEW     squid:S1213  
The members of an interface declaration or class should appear in a pre-defined order
Make this anonymous inner class a lambda (sonar.java.source not set. Assuming 8 or greater.)     NEW     squid:S1604  
Anonymous inner classes containing only one method should become lambdas
126
        public boolean accept(File dir, String name) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Add the "@Override" annotation above this method signature     NEW     squid:S1161  
"@Override" should be used on overriding and implementing methods
127
            return name.endsWith("k.txt");
Define a constant instead of duplicating this literal "k.txt" 3 times.     NEW     squid:S1192  
String literals should not be duplicated
128
        }
129
    };
130

                  
131
    @Test
132
    public void testListFilesInDirWithFiltere() throws Exception {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document this public method.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
Define and throw a dedicated exception instead of using a generic one.     NEW     squid:S00112  
Generic exceptions should never be thrown
133
        System.out.println(listFilesInDirWithFilter(path, "k.txt", false).toString());
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Replace this usage of System.out or System.err by a logger.     NEW     squid:S106  
Standard outputs should not be used directly to log anything
134
        System.out.println(listFilesInDirWithFilter(path, "k.txt", true).toString());
Replace this usage of System.out or System.err by a logger.     NEW     squid:S106  
Standard outputs should not be used directly to log anything
135
        System.out.println(listFilesInDirWithFilter(path, filter, false).toString());
Replace this usage of System.out or System.err by a logger.     NEW     squid:S106  
Standard outputs should not be used directly to log anything
136
        System.out.println(listFilesInDirWithFilter(path, filter, true).toString());
Replace this usage of System.out or System.err by a logger.     NEW     squid:S106  
Standard outputs should not be used directly to log anything
137
    }
138

                  
139
    @Test
140
    public void testSearchFile() throws Exception {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document this public method.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
Define and throw a dedicated exception instead of using a generic one.     NEW     squid:S00112  
Generic exceptions should never be thrown
141
        System.out.println(searchFileInDir(path, "GBK.txt").toString());
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Replace this usage of System.out or System.err by a logger.     NEW     squid:S106  
Standard outputs should not be used directly to log anything
142
        System.out.println(searchFileInDir(path, "child").toString());
Replace this usage of System.out or System.err by a logger.     NEW     squid:S106  
Standard outputs should not be used directly to log anything
143
    }
144

                  
145
    @Test
146
    public void testWriteFileFromIS() throws Exception {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document this public method.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
Define and throw a dedicated exception instead of using a generic one.     NEW     squid:S00112  
Generic exceptions should never be thrown
147
        assertThat(writeFileFromIS(path + "NEW.txt", new FileInputStream(path + "UTF8.txt"), false))
Define a constant instead of duplicating this literal "NEW.txt" 4 times.     NEW     squid:S1192  
String literals should not be duplicated
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
148
                .isTrue();
149
        assertThat(writeFileFromIS(path + "NEW.txt", new FileInputStream(path + "UTF8.txt"), true))
152

                  
153
    @Test
154
    public void testWriteFileFromString() throws Exception {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document this public method.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
Define and throw a dedicated exception instead of using a generic one.     NEW     squid:S00112  
Generic exceptions should never be thrown
155
        assertThat(writeFileFromString(path + "NEW.txt", "这是新的", false)).isTrue();
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
156
        assertThat(writeFileFromString(path + "NEW.txt", "\r\n这是追加的", true)).isTrue();
157
    }
158

                  
159
    @Test
160
    public void testGetFileCharsetSimple() throws Exception {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document this public method.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
Define and throw a dedicated exception instead of using a generic one.     NEW     squid:S00112  
Generic exceptions should never be thrown
161
        assertThat(getFileCharsetSimple(path + "GBK.txt")).isEqualTo("GBK");
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
162
        assertThat(getFileCharsetSimple(path + "Unicode.txt")).isEqualTo("Unicode");
163
        assertThat(getFileCharsetSimple(path + "UTF8.txt")).isEqualTo("UTF-8");
Define a constant instead of duplicating this literal "UTF-8" 4 times.     NEW     squid:S1192  
String literals should not be duplicated
164
        assertThat(getFileCharsetSimple(path + "UTF16BE.txt")).isEqualTo("UTF-16BE");
165
    }
166

                  
167
    @Test
168
    public void testGetFileLines() throws Exception {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document this public method.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
Define and throw a dedicated exception instead of using a generic one.     NEW     squid:S00112  
Generic exceptions should never be thrown
169
        assertThat(getFileLines(path + "UTF8.txt")).isEqualTo(7);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Assign this magic number 7 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
170
    }
171

                  
172
    @Test
173
    public void testReadFile2List() throws Exception {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document this public method.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
Define and throw a dedicated exception instead of using a generic one.     NEW     squid:S00112  
Generic exceptions should never be thrown
174
        System.out.println(readFile2List(path + "UTF8.txt", "").toString());
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Replace this usage of System.out or System.err by a logger.     NEW     squid:S106  
Standard outputs should not be used directly to log anything
175
        System.out.println(readFile2List(path + "UTF8.txt", "UTF-8").toString());
Replace this usage of System.out or System.err by a logger.     NEW     squid:S106  
Standard outputs should not be used directly to log anything
176
        System.out.println(readFile2List(path + "UTF8.txt", 2, 5, "UTF-8").toString());
Replace this usage of System.out or System.err by a logger.     NEW     squid:S106  
Standard outputs should not be used directly to log anything
Assign this magic number 2 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 5 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
177
        System.out.println(readFile2List(path + "UTF8.txt", "GBK").toString());
Replace this usage of System.out or System.err by a logger.     NEW     squid:S106  
Standard outputs should not be used directly to log anything
178
    }
179

                  
180
    @Test
181
    public void testReadFile2String() throws Exception {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document this public method.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
Define and throw a dedicated exception instead of using a generic one.     NEW     squid:S00112  
Generic exceptions should never be thrown
182
        System.out.println(readFile2String(path + "UTF8.txt", ""));
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Replace this usage of System.out or System.err by a logger.     NEW     squid:S106  
Standard outputs should not be used directly to log anything
183
        System.out.println(readFile2String(path + "UTF8.txt", "UTF-8"));
Replace this usage of System.out or System.err by a logger.     NEW     squid:S106  
Standard outputs should not be used directly to log anything
184
        System.out.println(readFile2String(path + "UTF8.txt", "GBK"));
Replace this usage of System.out or System.err by a logger.     NEW     squid:S106  
Standard outputs should not be used directly to log anything
185
    }
186

                  
187
    @Test
188
    public void testReadFile2Bytes() throws Exception {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document this public method.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
Define and throw a dedicated exception instead of using a generic one.     NEW     squid:S00112  
Generic exceptions should never be thrown
189
        System.out.println(new String(readFile2Bytes(path + "UTF8.txt")));
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Replace this usage of System.out or System.err by a logger.     NEW     squid:S106  
Standard outputs should not be used directly to log anything
190
    }
191

                  
192
    @Test
193
    public void testGetFileSize() throws Exception {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document this public method.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
Define and throw a dedicated exception instead of using a generic one.     NEW     squid:S00112  
Generic exceptions should never be thrown
194
        assertThat(getFileSize(path + "UTF8.txt")).isEqualTo("25B");
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
195
    }
196

                  
197
    @Test
198
    public void testGetDirName() throws Exception {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document this public method.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
Define and throw a dedicated exception instead of using a generic one.     NEW     squid:S00112  
Generic exceptions should never be thrown
199
        assertThat(getDirName(new File(path + "UTF8.txt"))).isEqualTo(path);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
200
        assertThat(getDirName(path + "UTF8.txt")).isEqualTo(path);
201
    }
202

                  
203
    @Test
204
    public void testGetFileName() throws Exception {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document this public method.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
Define and throw a dedicated exception instead of using a generic one.     NEW     squid:S00112  
Generic exceptions should never be thrown
205
        assertThat(getFileName(new File(path + "UTF8.txt"))).isEqualTo("UTF8.txt");
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
206
        assertThat(getFileName(path + "UTF8.txt")).isEqualTo("UTF8.txt");
207
    }
208

                  
209
    @Test
210
    public void testGetFileNameNoExtension() throws Exception {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document this public method.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
Define and throw a dedicated exception instead of using a generic one.     NEW     squid:S00112  
Generic exceptions should never be thrown
211
        assertThat(getFileNameNoExtension(new File(path + "UTF8.txt"))).isEqualTo("UTF8");
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
212
        assertThat(getFileNameNoExtension(path + "UTF8.txt")).isEqualTo("UTF8");
213
    }
214

                  
215
    @Test
216
    public void testGetFileExtension() throws Exception {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document this public method.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
Define and throw a dedicated exception instead of using a generic one.     NEW     squid:S00112  
Generic exceptions should never be thrown
217
        assertThat(getFileExtension(new File(path + "UTF8.txt"))).isEqualTo(".txt");
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
218
        assertThat(getFileExtension(path + "UTF8.txt")).isEqualTo(".txt");
219
    }
49
New issues
Add or update the header of this file.     NEW     squid:S1451
Copyright and license headers should be defined
Add a new line at the end of this file.     NEW     squid:S00113
Files should contain an empty new line at the end
1
package com.blankj.utilcode.utils;
2

                  
14
 * </pre>
15
 */
16
public class RegexUtilsTest {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
17

                  
18
    @Test
19
    public void testIsMobileSimple() throws Exception {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Make this line start at column 3.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Document this public method.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
Define and throw a dedicated exception instead of using a generic one.     NEW     squid:S00112  
Generic exceptions should never be thrown
20
        assertThat(isMobileSimple("11111111111")).isTrue();
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
21
    }
22

                  
23
    @Test
24
    public void testIsMobileExact() throws Exception {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document this public method.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
Define and throw a dedicated exception instead of using a generic one.     NEW     squid:S00112  
Generic exceptions should never be thrown
25
        assertThat(isMobileExact("11111111111")).isFalse();
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
26
        assertThat(isMobileExact("13888880000")).isTrue();
27
    }
28

                  
29
    @Test
30
    public void testIsTel() throws Exception {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document this public method.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
Define and throw a dedicated exception instead of using a generic one.     NEW     squid:S00112  
Generic exceptions should never be thrown
31
        assertThat(isTel("033-88888888")).isTrue();
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
32
        assertThat(isTel("033-7777777")).isTrue();
33
        assertThat(isTel("0444-88888888")).isTrue();
48

                  
49
    @Test
50
    public void testIsIDCard() throws Exception {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document this public method.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
Define and throw a dedicated exception instead of using a generic one.     NEW     squid:S00112  
Generic exceptions should never be thrown
51
        assertThat(isIDCard18("33698418400112523x")).isTrue();
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
52
        assertThat(isIDCard18("336984184001125233")).isTrue();
53
        assertThat(isIDCard18("336984184021125233")).isFalse();
55

                  
56
    @Test
57
    public void testIsEmail() throws Exception {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document this public method.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
Define and throw a dedicated exception instead of using a generic one.     NEW     squid:S00112  
Generic exceptions should never be thrown
58
        assertThat(isEmail("blankj@qq.com")).isTrue();
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
59
        assertThat(isEmail("blankj@qq")).isFalse();
60
    }
61

                  
62
    @Test
63
    public void testIsURL() throws Exception {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document this public method.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
Define and throw a dedicated exception instead of using a generic one.     NEW     squid:S00112  
Generic exceptions should never be thrown
64
        assertThat(isURL("http://blankj.com")).isTrue();
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
65
        assertThat(isURL("http://blank")).isFalse();
66
    }
67

                  
68
    @Test
69
    public void testIsChz() throws Exception {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document this public method.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
Define and throw a dedicated exception instead of using a generic one.     NEW     squid:S00112  
Generic exceptions should never be thrown
70
        assertThat(isChz("我")).isTrue();
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
71
        assertThat(isChz("wo")).isFalse();
72
    }
73

                  
74
    @Test
75
    public void testIsUsername() throws Exception {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document this public method.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
Define and throw a dedicated exception instead of using a generic one.     NEW     squid:S00112  
Generic exceptions should never be thrown
76
        assertThat(isUsername("小明233333")).isTrue();
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
77
        assertThat(isUsername("小明")).isFalse();
78
        assertThat(isUsername("小明233333_")).isFalse();
80

                  
81
    @Test
82
    public void testIsDate() throws Exception {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document this public method.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
Define and throw a dedicated exception instead of using a generic one.     NEW     squid:S00112  
Generic exceptions should never be thrown
83
        assertThat(isDate("2016-08-16")).isTrue();
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
84
        assertThat(isDate("2016-02-29")).isTrue();
85
        assertThat(isDate("2015-02-29")).isFalse();
88

                  
89
    @Test
90
    public void testIsIP() throws Exception {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document this public method.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
Define and throw a dedicated exception instead of using a generic one.     NEW     squid:S00112  
Generic exceptions should never be thrown
91
        assertThat(isIP("255.255.255.0")).isTrue();
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Make this IP "255.255.255.0" address configurable.     NEW     squid:S1313  
IP addresses should not be hardcoded
92
        assertThat(isIP("256.255.255.0")).isFalse();
93
    }
94

                  
95
    @Test
96
    public void testIsMatch() throws Exception {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document this public method.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
Define and throw a dedicated exception instead of using a generic one.     NEW     squid:S00112  
Generic exceptions should never be thrown
97
        assertThat(isMatch("\\d?", "1")).isTrue();
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
98
        assertThat(isMatch("\\d?", "a")).isFalse();
99
    }
14
New issues
Add or update the header of this file.     NEW     squid:S1451
Copyright and license headers should be defined
Add a new line at the end of this file.     NEW     squid:S00113
Files should contain an empty new line at the end
1
package com.blankj.utilcode.utils;
2

                  
16
@RunWith(RobolectricTestRunner.class)
17
@Config(manifest = Config.NONE)
18
public class SDCardUtilsTest {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
19

                  
20
    @Test
21
    public void testIsSDCardEnable() throws Exception {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Make this line start at column 3.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Document this public method.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
Define and throw a dedicated exception instead of using a generic one.     NEW     squid:S00112  
Generic exceptions should never be thrown
22
        System.out.println(SDCardUtils.isSDCardEnable());
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Replace this usage of System.out or System.err by a logger.     NEW     squid:S106  
Standard outputs should not be used directly to log anything
23
    }
24

                  
25
    @Test
26
    public void testGetSDCardPath() throws Exception {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document this public method.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
Define and throw a dedicated exception instead of using a generic one.     NEW     squid:S00112  
Generic exceptions should never be thrown
27
        System.out.println(SDCardUtils.getSDCardPath());
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Replace this usage of System.out or System.err by a logger.     NEW     squid:S106  
Standard outputs should not be used directly to log anything
28
    }
29
}
67
New issues
Add or update the header of this file.     NEW     squid:S1451
Copyright and license headers should be defined
Add a new line at the end of this file.     NEW     squid:S00113
Files should contain an empty new line at the end
1
package com.blankj.utilcode.utils;
2

                  
21
@RunWith(RobolectricTestRunner.class)
22
@Config(manifest = Config.NONE)
23
public class SPUtilsTest {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
24

                  
25
    SPUtils spUtils;
Explicitly declare the visibility for "spUtils".     NEW     squid:S2039  
Member variable visibility should be specified
Make this line start at column 3.     NEW     squid:IndentationCheck  
Source code should be indented consistently
26

                  
27
    @Before
28
    public void setUp() throws Exception {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document this public method.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
Define and throw a dedicated exception instead of using a generic one.     NEW     squid:S00112  
Generic exceptions should never be thrown
29
        if (spUtils == null) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
30
            spUtils = new SPUtils(TestUtils.getContext(), "test");
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
31
            spUtils.putString("stringKey", "stringVal");
Define a constant instead of duplicating this literal "stringKey" 4 times.     NEW     squid:S1192  
String literals should not be duplicated
32
            spUtils.putInt("intKey", 1);
33
            spUtils.putLong("longKey", 1L);
34
            spUtils.putFloat("floatKey", 1f);
Upper-case this literal "f" suffix.     NEW     squid:S818  
Literal suffixes should be upper case
35
            spUtils.putBoolean("booleanKey", true);
36
        }
38

                  
39
    @Test
40
    public void testGetString() throws Exception {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document this public method.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
Define and throw a dedicated exception instead of using a generic one.     NEW     squid:S00112  
Generic exceptions should never be thrown
41
        assertThat(spUtils.getString("stringKey")).isEqualTo("stringVal");
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
42
        assertThat(spUtils.getString("stringKey1", "stringVal1")).isEqualTo("stringVal1");
43
        assertThat(spUtils.getString("stringKey1")).isNull();
45

                  
46
    @Test
47
    public void testGetInt() throws Exception {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document this public method.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
Define and throw a dedicated exception instead of using a generic one.     NEW     squid:S00112  
Generic exceptions should never be thrown
48
        assertThat(spUtils.getInt("intKey")).isEqualTo(1);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
49
        assertThat(spUtils.getInt("intKey1", 10086)).isEqualTo(10086);
Assign this magic number 10086 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 10086 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
50
        assertThat(spUtils.getInt("intKey1")).isEqualTo(-1);
51
    }
52

                  
53
    @Test
54
    public void testGetLong() throws Exception {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document this public method.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
Define and throw a dedicated exception instead of using a generic one.     NEW     squid:S00112  
Generic exceptions should never be thrown
55
        assertThat(spUtils.getLong("longKey")).isEqualTo(1L);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
56
        assertThat(spUtils.getLong("longKey1", 10086L)).isEqualTo(10086L);
Assign this magic number 10086L to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 10086L to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
57
        assertThat(spUtils.getLong("longKey1")).isEqualTo(-1L);
58
    }
59

                  
60
    @Test
61
    public void testGetFloat() throws Exception {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document this public method.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
Define and throw a dedicated exception instead of using a generic one.     NEW     squid:S00112  
Generic exceptions should never be thrown
62
        assertThat(spUtils.getFloat("floatKey") - 1.f).isWithin(0.f);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Upper-case this literal "f" suffix.     NEW     squid:S818  
Literal suffixes should be upper case
Upper-case this literal "f" suffix.     NEW     squid:S818  
Literal suffixes should be upper case
63
        assertThat(spUtils.getFloat("floatKey1", 10086f) - 10086f).isWithin(0.f);
Upper-case this literal "f" suffix.     NEW     squid:S818  
Literal suffixes should be upper case
Upper-case this literal "f" suffix.     NEW     squid:S818  
Literal suffixes should be upper case
Upper-case this literal "f" suffix.     NEW     squid:S818  
Literal suffixes should be upper case
Assign this magic number 10086f to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 10086f to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
64
        assertThat(spUtils.getFloat("floatKey1") + 1.f).isWithin(0.f);
Upper-case this literal "f" suffix.     NEW     squid:S818  
Literal suffixes should be upper case
Upper-case this literal "f" suffix.     NEW     squid:S818  
Literal suffixes should be upper case
65
    }
66

                  
67
    @Test
68
    public void testGetBoolean() throws Exception {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document this public method.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
Define and throw a dedicated exception instead of using a generic one.     NEW     squid:S00112  
Generic exceptions should never be thrown
69
        assertThat(spUtils.getBoolean("booleanKey")).isTrue();
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
70
        assertThat(spUtils.getBoolean("booleanKey1", true)).isTrue();
71
        assertThat(spUtils.getBoolean("booleanKey1")).isFalse();
73

                  
74
    @Test
75
    public void testGetAll() throws Exception {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document this public method.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
Define and throw a dedicated exception instead of using a generic one.     NEW     squid:S00112  
Generic exceptions should never be thrown
76
        Map<String, ?> map = spUtils.getAll();
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
77
        for (Map.Entry<String, ?> entry : map.entrySet()) {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
78
            System.out.println("Key = " + entry.getKey() + ", Value = " + entry.getValue());
Make this line start at column 7.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Replace this usage of System.out or System.err by a logger.     NEW     squid:S106  
Standard outputs should not be used directly to log anything
79
        }
80
    }
81

                  
82
    @Test
83
    public void testRemove() throws Exception {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document this public method.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
84
        spUtils.remove("stringKey");
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
85
        testGetAll();
86
    }
87

                  
88
    @Test
89
    public void testContains() throws Exception {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document this public method.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
Define and throw a dedicated exception instead of using a generic one.     NEW     squid:S00112  
Generic exceptions should never be thrown
90
        assertThat(spUtils.contains("stringKey")).isTrue();
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
91
        assertThat(spUtils.contains("string")).isFalse();
92
    }
93

                  
94
    @Test
95
    public void testClear() throws Exception {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document this public method.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
96
        spUtils.clear();
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
97
        testGetAll();
98
    }
49
New issues
Add or update the header of this file.     NEW     squid:S1451
Copyright and license headers should be defined
Add a new line at the end of this file.     NEW     squid:S00113
Files should contain an empty new line at the end
1
package com.blankj.utilcode.utils;
2

                  
14
 * </pre>
15
 */
16
public class StringUtilsTest {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
17

                  
18
    @Test
19
    public void testIsEmpty() throws Exception {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Make this line start at column 3.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Document this public method.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
Define and throw a dedicated exception instead of using a generic one.     NEW     squid:S00112  
Generic exceptions should never be thrown
20
        assertThat(isEmpty("")).isTrue();
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
21
        assertThat(isEmpty(null)).isTrue();
22
        assertThat(isEmpty(" ")).isFalse();
24

                  
25
    @Test
26
    public void testIsSpace() throws Exception {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document this public method.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
Define and throw a dedicated exception instead of using a generic one.     NEW     squid:S00112  
Generic exceptions should never be thrown
27
        assertThat(isSpace("")).isTrue();
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
28
        assertThat(isSpace(null)).isTrue();
29
        assertThat(isSpace(" ")).isTrue();
32

                  
33
    @Test
34
    public void testNull2Length0() throws Exception {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document this public method.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
Define and throw a dedicated exception instead of using a generic one.     NEW     squid:S00112  
Generic exceptions should never be thrown
35
        assertThat(null2Length0(null)).isEqualTo("");
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
36
    }
37

                  
38
    @Test
39
    public void testLength() throws Exception {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document this public method.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
Define and throw a dedicated exception instead of using a generic one.     NEW     squid:S00112  
Generic exceptions should never be thrown
40
        assertThat(length(null)).isEqualTo(0);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
41
        assertThat(length("")).isEqualTo(0);
42
        assertThat(length("blankj")).isEqualTo(6);
Define a constant instead of duplicating this literal "blankj" 6 times.     NEW     squid:S1192  
String literals should not be duplicated
Assign this magic number 6 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
43
    }
44

                  
45
    @Test
46
    public void testUpperFirstLetter() throws Exception {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document this public method.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
Define and throw a dedicated exception instead of using a generic one.     NEW     squid:S00112  
Generic exceptions should never be thrown
47
        assertThat(upperFirstLetter("blankj")).isEqualTo("Blankj");
Define a constant instead of duplicating this literal "Blankj" 4 times.     NEW     squid:S1192  
String literals should not be duplicated
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
48
        assertThat(upperFirstLetter("Blankj")).isEqualTo("Blankj");
49
        assertThat(upperFirstLetter("1Blankj")).isEqualTo("1Blankj");
51

                  
52
    @Test
53
    public void testLowerFirstLetter() throws Exception {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document this public method.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
Define and throw a dedicated exception instead of using a generic one.     NEW     squid:S00112  
Generic exceptions should never be thrown
54
        assertThat(lowerFirstLetter("blankj")).isEqualTo("blankj");
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
55
        assertThat(lowerFirstLetter("Blankj")).isEqualTo("blankj");
56
        assertThat(lowerFirstLetter("1blankj")).isEqualTo("1blankj");
58

                  
59
    @Test
60
    public void testReverse() throws Exception {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document this public method.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
Define and throw a dedicated exception instead of using a generic one.     NEW     squid:S00112  
Generic exceptions should never be thrown
61
        assertThat(reverse("blankj")).isEqualTo("jknalb");
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
62
        assertThat(reverse("blank")).isEqualTo("knalb");
63
        assertThat(reverse("测试中文")).isEqualTo("文中试测");
66

                  
67
    @Test
68
    public void testToDBC() throws Exception {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document this public method.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
Define and throw a dedicated exception instead of using a generic one.     NEW     squid:S00112  
Generic exceptions should never be thrown
69
        assertThat(toDBC(" ,.&")).isEqualTo(" ,.&");
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
70
    }
71

                  
72
    @Test
73
    public void testToSBC() throws Exception {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document this public method.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
Define and throw a dedicated exception instead of using a generic one.     NEW     squid:S00112  
Generic exceptions should never be thrown
74
        assertThat(toSBC(" ,.&")).isEqualTo(" ,.&");
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
75
    }
76

                  
77
    @Test
78
    public void test() throws Exception {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document this public method.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
Define and throw a dedicated exception instead of using a generic one.     NEW     squid:S00112  
Generic exceptions should never be thrown
79
        System.out.println(StringUtils.getPYFirstLetter("c"));
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Replace this usage of System.out or System.err by a logger.     NEW     squid:S106  
Standard outputs should not be used directly to log anything
80
        System.out.println(StringUtils.cn2PY("测试转拼音"));
Replace this usage of System.out or System.err by a logger.     NEW     squid:S106  
Standard outputs should not be used directly to log anything
81
    }
82
}
9
New issues
Add or update the header of this file.     NEW     squid:S1451
Copyright and license headers should be defined
1
package com.blankj.utilcode.utils;
2

                  
24
@RunWith(RobolectricTestRunner.class)
25
@Config(manifest = Config.NONE)
26
public class TestUtils {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
27

                  
28
    public static final char SEP = File.separatorChar;
Make this line start at column 3.     NEW     squid:IndentationCheck  
Source code should be indented consistently
29

                  
30
    public static final String BASEPATH = System.getProperty("user.dir")
31
            + SEP + "src" + SEP + "test" + SEP + "res" + SEP;
32

                  
33
    public static Context getContext() {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
34
        return RuntimeEnvironment.application;
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
35
    }
36

                  
37
    @Test
38
    public void test() throws Exception {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document this public method.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
Define and throw a dedicated exception instead of using a generic one.     NEW     squid:S00112  
Generic exceptions should never be thrown
Add a nested comment explaining why this method is empty, throw an UnsupportedOperationException or complete the implementation.     NEW     squid:S1186  
Methods should not be empty
39

                  
40
    }
70
New issues
Add or update the header of this file.     NEW     squid:S1451
Copyright and license headers should be defined
Add a new line at the end of this file.     NEW     squid:S00113
Files should contain an empty new line at the end
1
package com.blankj.utilcode.utils;
2

                  
19
 * </pre>
20
 */
21
public class TimeUtilsTest {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
22

                  
23

                  
24
    SimpleDateFormat myFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss zzzz", Locale.getDefault());
Explicitly declare the visibility for "myFormat".     NEW     squid:S2039  
Member variable visibility should be specified
Make this line start at column 3.     NEW     squid:IndentationCheck  
Source code should be indented consistently
25
    long milliseconds = 1470991049000L;
Explicitly declare the visibility for "milliseconds".     NEW     squid:S2039  
Member variable visibility should be specified
Assign this magic number 1470991049000L to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
26
    Date timeDate = new Date(milliseconds);
Explicitly declare the visibility for "timeDate".     NEW     squid:S2039  
Member variable visibility should be specified
27
    String timeString = "2016-08-12 16:37:29";
Explicitly declare the visibility for "timeString".     NEW     squid:S2039  
Member variable visibility should be specified
28
    String myTimeString = "2016-08-12 16:37:29 中国标准时间";
Explicitly declare the visibility for "myTimeString".     NEW     squid:S2039  
Member variable visibility should be specified
29
    String timeString0 = "2016-08-12 16:00:00";
Explicitly declare the visibility for "timeString0".     NEW     squid:S2039  
Member variable visibility should be specified
30
    String timeString1 = "2016-08-12 17:10:10";
Explicitly declare the visibility for "timeString1".     NEW     squid:S2039  
Member variable visibility should be specified
31
    String myTimeString0 = "2016-08-12 16:00:00 中国标准时间";
Explicitly declare the visibility for "myTimeString0".     NEW     squid:S2039  
Member variable visibility should be specified
32
    String myTimeString1 = "2016-08-12 17:10:10 中国标准时间";
Explicitly declare the visibility for "myTimeString1".     NEW     squid:S2039  
Member variable visibility should be specified
33

                  
34

                  
35
    @Test
36
    public void testMilliseconds2String() throws Exception {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document this public method.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
Define and throw a dedicated exception instead of using a generic one.     NEW     squid:S00112  
Generic exceptions should never be thrown
37
        assertThat(milliseconds2String(milliseconds)).isEqualTo(timeString);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
38
        assertThat(milliseconds2String(milliseconds, myFormat)).isEqualTo(myTimeString);
39
    }
40

                  
41
    @Test
42
    public void testString2Milliseconds() throws Exception {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document this public method.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
Define and throw a dedicated exception instead of using a generic one.     NEW     squid:S00112  
Generic exceptions should never be thrown
43
        assertThat(string2Milliseconds(timeString)).isEqualTo(milliseconds);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
44
        assertThat(string2Milliseconds(myTimeString, myFormat)).isEqualTo(milliseconds);
45
    }
46

                  
47
    @Test
48
    public void testString2Date() throws Exception {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document this public method.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
Define and throw a dedicated exception instead of using a generic one.     NEW     squid:S00112  
Generic exceptions should never be thrown
49
        assertThat(string2Date(timeString)).isEqualTo(timeDate);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
50
        assertThat(string2Date(myTimeString, myFormat)).isEqualTo(timeDate);
51
    }
52

                  
53
    @Test
54
    public void testDate2String() throws Exception {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document this public method.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
Define and throw a dedicated exception instead of using a generic one.     NEW     squid:S00112  
Generic exceptions should never be thrown
55
        assertThat(date2String(timeDate)).isEqualTo(timeString);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
56
        assertThat(date2String(timeDate, myFormat)).isEqualTo(myTimeString);
57
    }
58

                  
59
    @Test
60
    public void testDate2Milliseconds() throws Exception {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document this public method.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
Define and throw a dedicated exception instead of using a generic one.     NEW     squid:S00112  
Generic exceptions should never be thrown
61
        assertThat(date2Milliseconds(timeDate)).isEqualTo(milliseconds);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
62
    }
63

                  
64
    @Test
65
    public void testMilliseconds2Date() throws Exception {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document this public method.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
Define and throw a dedicated exception instead of using a generic one.     NEW     squid:S00112  
Generic exceptions should never be thrown
66
        assertThat(milliseconds2Date(milliseconds)).isEqualTo(timeDate);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
67
    }
68

                  
69
    @Test
70
    public void testGetIntervalTime() throws Exception {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document this public method.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
Define and throw a dedicated exception instead of using a generic one.     NEW     squid:S00112  
Generic exceptions should never be thrown
71
        assertThat(getIntervalTime(timeString0, timeString1, ConstUtils.TimeUnit.SEC)).isEqualTo(4210);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Assign this magic number 4210 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
72
        assertThat(getIntervalTime(myTimeString0, myTimeString1, ConstUtils.TimeUnit.SEC, myFormat)).isEqualTo(4210);
Assign this magic number 4210 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
73
        assertThat(getIntervalTime(new Date(4210000), new Date(0), ConstUtils.TimeUnit.SEC)).isEqualTo(4210);
Assign this magic number 4210000 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Assign this magic number 4210 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
Add underscores to this numeric value for readability     NEW     squid:S2148  
Underscores should be used to make large numbers readable
74
    }
75

                  
76
    @Test
77
    public void testGetCurTimeMills() throws Exception {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document this public method.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
Define and throw a dedicated exception instead of using a generic one.     NEW     squid:S00112  
Generic exceptions should never be thrown
78
        long interval = getCurTimeMills() - System.currentTimeMillis();
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
79
        assertThat(interval).isLessThan(10L);
Assign this magic number 10L to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
80
    }
81

                  
82
    @Test
83
    public void testGetCurTimeString() throws Exception {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document this public method.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
Define and throw a dedicated exception instead of using a generic one.     NEW     squid:S00112  
Generic exceptions should never be thrown
84
        System.out.println(getCurTimeString());
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Replace this usage of System.out or System.err by a logger.     NEW     squid:S106  
Standard outputs should not be used directly to log anything
85
        System.out.println(getCurTimeString(myFormat));
Replace this usage of System.out or System.err by a logger.     NEW     squid:S106  
Standard outputs should not be used directly to log anything
86
    }
87

                  
88
    @Test
89
    public void testGetIntervalByNow() throws Exception {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document this public method.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
Define and throw a dedicated exception instead of using a generic one.     NEW     squid:S00112  
Generic exceptions should never be thrown
Add a nested comment explaining why this method is empty, throw an UnsupportedOperationException or complete the implementation.     NEW     squid:S1186  
Methods should not be empty
90

                  
91
    }
92

                  
93
    @Test
94
    public void testIsLeapYear() throws Exception {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document this public method.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
Define and throw a dedicated exception instead of using a generic one.     NEW     squid:S00112  
Generic exceptions should never be thrown
95
        assertThat(isLeapYear(2012)).isEqualTo(true);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Assign this magic number 2012 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
96
        assertThat(isLeapYear(2000)).isEqualTo(true);
Assign this magic number 2000 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
97
        assertThat(isLeapYear(1900)).isEqualTo(false);
Assign this magic number 1900 to a well-named constant, and use the constant instead.     NEW     squid:S109  
Magic numbers should not be used
98
    }
99
}
39
New issues
Add or update the header of this file.     NEW     squid:S1451
Copyright and license headers should be defined
Add a new line at the end of this file.     NEW     squid:S00113
Files should contain an empty new line at the end
1
package com.blankj.utilcode.utils;
2

                  
20
 * </pre>
21
 */
22
public class ZipUtilsTest {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
23

                  
24
    String testZip = BASEPATH + "zip" + SEP + "testZip" + SEP;
Explicitly declare the visibility for "testZip".     NEW     squid:S2039  
Member variable visibility should be specified
Make this line start at column 3.     NEW     squid:IndentationCheck  
Source code should be indented consistently
25
    String testZipFiles = BASEPATH + "zip" + SEP + "testZips.zip";
Explicitly declare the visibility for "testZipFiles".     NEW     squid:S2039  
Member variable visibility should be specified
26
    String testZipFile = BASEPATH + "zip" + SEP + "testZip.zip";
Explicitly declare the visibility for "testZipFile".     NEW     squid:S2039  
Member variable visibility should be specified
27
    String unzipFile = BASEPATH + "zip" + SEP + "testUnzip";
Explicitly declare the visibility for "unzipFile".     NEW     squid:S2039  
Member variable visibility should be specified
28

                  
29
    @Test
30
    public void testZipFiles() throws Exception {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document this public method.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
Define and throw a dedicated exception instead of using a generic one.     NEW     squid:S00112  
Generic exceptions should never be thrown
31
        List<File> files = FileUtils.listFilesInDir(testZip, false);
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
32
        FileUtils.createOrExistsFile(testZipFiles);
33
        zipFiles(files, testZipFiles);
35

                  
36
    @Test
37
    public void testZipFile() throws Exception {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document this public method.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
Define and throw a dedicated exception instead of using a generic one.     NEW     squid:S00112  
Generic exceptions should never be thrown
38
        zipFile(testZip, testZipFile, "测试zip");
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
39
    }
40

                  
41
    @Test
42
    public void testUpZipFile() throws Exception {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document this public method.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
Define and throw a dedicated exception instead of using a generic one.     NEW     squid:S00112  
Generic exceptions should never be thrown
43
        assertThat(unzipFile(testZipFile, unzipFile)).isTrue();
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
44
        assertThat(unzipFile(testZipFiles, unzipFile)).isTrue();
45
    }
46

                  
47
    @Test
48
    public void testUpZipFiles() throws Exception {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document this public method.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
Define and throw a dedicated exception instead of using a generic one.     NEW     squid:S00112  
Generic exceptions should never be thrown
49
        List<File> files = new ArrayList<>();
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
50
        files.add(new File(testZipFile));
51
        files.add(new File(testZipFiles));
54

                  
55
    @Test
56
    public void testUnzipFileByKeyword() throws Exception {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document this public method.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
Define and throw a dedicated exception instead of using a generic one.     NEW     squid:S00112  
Generic exceptions should never be thrown
57
        System.out.println((unzipFileByKeyword(testZipFile, unzipFile, ".txt")).toString());
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Replace this usage of System.out or System.err by a logger.     NEW     squid:S106  
Standard outputs should not be used directly to log anything
58
    }
59

                  
60
    @Test
61
    public void testGetFileNamesInZip() throws Exception {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document this public method.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
Define and throw a dedicated exception instead of using a generic one.     NEW     squid:S00112  
Generic exceptions should never be thrown
62
        System.out.println(getFilesPath(testZipFile));
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Replace this usage of System.out or System.err by a logger.     NEW     squid:S106  
Standard outputs should not be used directly to log anything
63
    }
64

                  
65
    @Test
66
    public void testGetComments() throws Exception {
Move this left curly brace to the beginning of next line of code.     NEW     squid:LeftCurlyBraceStartLineCheck  
An open curly brace should be located at the beginning of a line
Document this public method.     NEW     squid:UndocumentedApi  
Public types, methods and fields (API) should be documented with Javadoc
Define and throw a dedicated exception instead of using a generic one.     NEW     squid:S00112  
Generic exceptions should never be thrown
67
        System.out.println(getComments(testZipFile));
Make this line start at column 5.     NEW     squid:IndentationCheck  
Source code should be indented consistently
Replace this usage of System.out or System.err by a logger.     NEW     squid:S106  
Standard outputs should not be used directly to log anything
68
    }
69
}